@nativescript-community/ui-zoomimage
Version:
Zoomable image view based on @nativescript-community/ui-image
78 lines • 3.09 kB
JavaScript
export * from './index-common';
import { ZoomImageBase, maxZoomScaleProperty, minZoomScaleProperty, zoomScaleProperty } from './index-common';
var UIZoomImgScrollViewDelegateImpl = /** @class */ (function (_super) {
__extends(UIZoomImgScrollViewDelegateImpl, _super);
function UIZoomImgScrollViewDelegateImpl() {
return _super !== null && _super.apply(this, arguments) || this;
}
UIZoomImgScrollViewDelegateImpl.initWithOwner = function (owner) {
var delegate = new UIZoomImgScrollViewDelegateImpl();
delegate.owner = owner;
return delegate;
};
UIZoomImgScrollViewDelegateImpl.prototype.viewForZoomingInScrollView = function (scrollView) {
var owner = this.owner.get();
return owner === null || owner === void 0 ? void 0 : owner.nativeImageViewProtected;
};
UIZoomImgScrollViewDelegateImpl.ObjCProtocols = [UIScrollViewDelegate];
return UIZoomImgScrollViewDelegateImpl;
}(NSObject));
export { UIZoomImgScrollViewDelegateImpl };
export class ZoomImg extends ZoomImageBase {
createNativeView() {
this._image = super.createNativeView();
this._image.clipsToBounds = true;
const nativeView = ImageScrollView.new();
nativeView.zoomView = this._image;
// const nativeView = UIScrollView.new();
// nativeView.addSubview(this._image);
nativeView.zoomScale = this.zoomScale;
nativeView.minimumZoomScale = this.minZoom;
nativeView.maximumZoomScale = this.maxZoom;
return nativeView;
}
_setNativeImage(nativeImage, animated = true) {
//@ts-ignore
super._setNativeImage(nativeImage, animated);
if (nativeImage) {
this.nativeViewProtected.updateForImage(nativeImage.size);
}
}
get nativeImageViewProtected() {
return this._image;
}
initNativeView() {
this.delegate = UIZoomImgScrollViewDelegateImpl.initWithOwner(new WeakRef(this));
this.nativeViewProtected.delegate = this.delegate;
}
disposeNativeView() {
super.disposeNativeView();
this._image = null;
this.nativeViewProtected.delegate = this.delegate = null;
}
onLayout(left, top, right, bottom) {
super.onLayout(left, top, right, bottom);
this.nativeImageViewProtected.frame = this.nativeViewProtected.bounds;
}
[zoomScaleProperty.setNative](scale) {
if (this.nativeViewProtected) {
this.nativeViewProtected.zoomScale = scale;
}
}
setZoom(scale, animated = true, point = { x: 0, y: 0 }) {
if (this.nativeViewProtected) {
this.nativeViewProtected.setZoomScaleAnimated(scale, animated);
}
}
[minZoomScaleProperty.setNative](scale) {
if (this.nativeViewProtected) {
this.nativeViewProtected.minimumZoomScale = scale;
}
}
[maxZoomScaleProperty.setNative](scale) {
if (this.nativeViewProtected) {
this.nativeViewProtected.maximumZoomScale = scale;
}
}
}
//# sourceMappingURL=index.ios.js.map