@nativescript-community/ui-zoomimage
Version:
Zoomable image view based on @nativescript-community/ui-image
42 lines • 1.76 kB
JavaScript
export * from './index-common';
import { ZoomImageBase, maxZoomScaleProperty, minZoomScaleProperty, zoomScaleProperty } from './index-common';
export class ZoomImg extends ZoomImageBase {
constructor() {
super(...arguments);
this.mNeedUpdateHierarchy = true;
}
createNativeView() {
//@ts-ignore
const view = new com.facebook.samples.zoomable.ZoomableDraweeView(this._context);
view.setIsLongpressEnabled(false);
view.setAllowTouchInterceptionWhileZoomed(false);
//@ts-ignore
view.setTapListener(new com.facebook.samples.zoomable.DoubleTapGestureListener(view));
return view;
}
getController() {
return this.nativeViewProtected?.getZoomableController();
}
updateImageUri() {
// this prevents the controller from reseting the current transform
this.getController().ignoreNextResetUntilEnabled = true;
return super.updateImageUri();
}
[zoomScaleProperty.setNative](scale) {
//possible?
// if (this.nativeViewProtected) {
// this.nativeViewProtected.getZoomableController().setMinScaleFactor(scale);
// }
this.getController().zoomToPoint(scale, new android.graphics.PointF(0, 0), new android.graphics.PointF(0, 0));
}
setZoom(scale, animated = true, point = { x: 0, y: 0 }) {
this.getController().zoomToPoint(scale, new android.graphics.PointF(point.x, point.y), new android.graphics.PointF(0, 0));
}
[minZoomScaleProperty.setNative](scale) {
this.getController().setMinScaleFactor(scale);
}
[maxZoomScaleProperty.setNative](scale) {
this.getController().setMaxScaleFactor(scale);
}
}
//# sourceMappingURL=index.android.js.map