Skip to content

Commit 535e433

Browse files
author
farfromrefug
committed
fix(zoomimage): improvements
1 parent 7b2244a commit 535e433

File tree

4 files changed

+499
-5
lines changed

4 files changed

+499
-5
lines changed

src/zoomimage/index.android.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { ZoomImageBase, maxZoomScaleProperty, minZoomScaleProperty, zoomScalePro
33

44
export class ZoomImg extends ZoomImageBase {
55
mNeedUpdateHierarchy = true;
6-
//@ts-ignore
76
nativeViewProtected: com.facebook.samples.zoomable.ZoomableDraweeView;
8-
//@ts-ignore
97
nativeImageViewProtected: com.facebook.samples.zoomable.ZoomableDraweeView;
108
public createNativeView() {
119
//@ts-ignore
@@ -16,19 +14,25 @@ export class ZoomImg extends ZoomImageBase {
1614
view.setTapListener(new com.facebook.samples.zoomable.DoubleTapGestureListener(view));
1715
return view;
1816
}
17+
getController() {
18+
return this.nativeViewProtected?.getZoomableController() as com.facebook.samples.zoomable.DefaultZoomableController;
19+
}
1920

2021
[zoomScaleProperty.setNative](scale: number) {
2122
//possible?
2223
// if (this.nativeViewProtected) {
2324
// this.nativeViewProtected.getZoomableController().setMinScaleFactor(scale);
2425
// }
26+
this.getController().zoomToPoint(scale, new android.graphics.PointF(0, 0), new android.graphics.PointF(0, 0));
27+
}
28+
setZoom(scale: number, animated = true, point: { x; y } = { x: 0, y: 0 }) {
29+
this.getController().zoomToPoint(scale, new android.graphics.PointF(point.x, point.y), new android.graphics.PointF(0, 0));
2530
}
26-
2731
[minZoomScaleProperty.setNative](scale: number) {
28-
this.nativeViewProtected.getZoomableController().setMinScaleFactor(scale);
32+
this.getController().setMinScaleFactor(scale);
2933
}
3034

3135
[maxZoomScaleProperty.setNative](scale: number) {
32-
this.nativeViewProtected.getZoomableController().setMaxScaleFactor(scale);
36+
this.getController().setMaxScaleFactor(scale);
3337
}
3438
}

src/zoomimage/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
import { Img } from '@nativescript-community/ui-image';
12

23
export class ZoomImg extends Img {}

src/zoomimage/index.ios.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ export class ZoomImg extends ZoomImageBase {
5656
this.nativeViewProtected.zoomScale = scale;
5757
}
5858
}
59+
setZoom(scale: number, animated = true, point: { x; y } = { x: 0, y: 0 }) {
60+
if (this.nativeViewProtected) {
61+
this.nativeViewProtected.setZoomScaleAnimated(scale, animated);
62+
}
63+
}
5964

6065
[minZoomScaleProperty.setNative](scale: number) {
6166
if (this.nativeViewProtected) {

0 commit comments

Comments
 (0)