File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed
packages/zoomimage/platforms/android/java/com/facebook/samples/zoomable Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,10 @@ public interface ImageBoundsListener {
72
72
private final RectF mTempRect = new RectF ();
73
73
private boolean mWasTransformCorrected ;
74
74
75
+ // used to not reset transform on updateImageUri ( controller update )
76
+ public boolean ignoreNextResetUntilEnabled = false ;
77
+
78
+
75
79
public static DefaultZoomableController newInstance () {
76
80
return new DefaultZoomableController (TransformGestureDetector .newInstance ());
77
81
}
@@ -83,6 +87,9 @@ public DefaultZoomableController(TransformGestureDetector gestureDetector) {
83
87
84
88
/** Rests the controller. */
85
89
public void reset () {
90
+ if (ignoreNextResetUntilEnabled ) {
91
+ return ;
92
+ }
86
93
mGestureDetector .reset ();
87
94
mPreviousTransform .reset ();
88
95
mActiveTransform .reset ();
@@ -101,6 +108,8 @@ public void setEnabled(boolean enabled) {
101
108
mIsEnabled = enabled ;
102
109
if (!enabled ) {
103
110
reset ();
111
+ } else {
112
+ ignoreNextResetUntilEnabled = false ;
104
113
}
105
114
}
106
115
Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ export class ZoomImg extends ZoomImageBase {
18
18
return this . nativeViewProtected ?. getZoomableController ( ) as com . facebook . samples . zoomable . DefaultZoomableController ;
19
19
}
20
20
21
+ updateImageUri ( ) {
22
+ // this prevents the controller from reseting the current transform
23
+ this . getController ( ) . ignoreNextResetUntilEnabled = true ;
24
+ return super . updateImageUri ( ) ;
25
+ }
21
26
[ zoomScaleProperty . setNative ] ( scale : number ) {
22
27
//possible?
23
28
// if (this.nativeViewProtected) {
Original file line number Diff line number Diff line change @@ -213,6 +213,7 @@ declare namespace com {
213
213
public static LIMIT_TRANSLATION_Y : number = 2 ;
214
214
public static LIMIT_SCALE : number = 4 ;
215
215
public static LIMIT_ALL : number = 7 ;
216
+ public ignoreNextResetUntilEnabled : boolean ;
216
217
public mapViewToImage ( param0 : globalAndroid . graphics . PointF ) : globalAndroid . graphics . PointF ;
217
218
public isIdentity ( ) : boolean ;
218
219
public wasTransformCorrected ( ) : boolean ;
You can’t perform that action at this time.
0 commit comments