@@ -12,6 +12,7 @@ import {
1212 PanResponderGestureState ,
1313 Text ,
1414 SafeAreaView ,
15+ Platform ,
1516} from 'react-native' ;
1617import {
1718 HandlerStateChangeEvent ,
@@ -102,12 +103,13 @@ class Image extends React.Component<ImageComponentProps, ImageComponentState> {
102103 }
103104
104105 if ( Math . abs ( gesture . dx ) > Math . abs ( gesture . dy ) ) {
105- this . props . toggleEnableScroll ( true ) ;
106-
106+ this . _debug ( '_onPanResponderMove' , 'horizontal' ) ;
107+ this . props . onZoomStateChange ( false ) ;
107108 return ;
108109 }
109110
110- this . props . toggleEnableScroll ( false ) ;
111+ this . _debug ( '_onPanResponderMove' , 'vertical' ) ;
112+ this . props . onZoomStateChange ( true ) ;
111113 this . _translateXY . setValue ( { x : 0 , y : Math . max ( 0 , gesture . dy ) } ) ;
112114 }
113115 private _onPanResponderEnd ( _evt : any , gesture : PanResponderGestureState ) {
@@ -145,7 +147,6 @@ class Image extends React.Component<ImageComponentProps, ImageComponentState> {
145147 } ) . start ( ( ) => this . props . onClose ( ) ) ;
146148 } else {
147149 // fixed case swipe left when jump restart
148- this . props . toggleEnableScroll ( true ) ;
149150 Animated . spring ( this . _translateXY , {
150151 toValue : { x : 0 , y : 0 } ,
151152 useNativeDriver : true ,
@@ -176,7 +177,6 @@ class Image extends React.Component<ImageComponentProps, ImageComponentState> {
176177 ] ) . start ( ) ;
177178 this . _lastScale = 1 ;
178179 this . _lastOffset = { x : 0 , y : 0 } ;
179- this . props . toggleEnableScroll ( true ) ;
180180 } else {
181181 const scale =
182182 this . _getRatio ( ) <= this . _getMinimumScale ( ) ? this . _getMaximumScale ( ) : SCREEN_WIDTH / this . state . width ! ;
@@ -232,7 +232,6 @@ class Image extends React.Component<ImageComponentProps, ImageComponentState> {
232232 } ) ;
233233 this . _lastScale = scale ;
234234 this . _setIsZooming ( true ) ;
235- this . props . toggleEnableScroll ( false ) ;
236235 }
237236 } ;
238237
@@ -265,7 +264,7 @@ class Image extends React.Component<ImageComponentProps, ImageComponentState> {
265264 let scale = evt . nativeEvent . scale as number ;
266265 if ( scale < this . _getMinimumScale ( ) ) {
267266 scale = this . _getMinimumScale ( ) ;
268- this . props . toggleEnableScroll ( true ) ;
267+
269268 this . _setIsZooming ( false ) ;
270269 } else {
271270 scale = Math . min ( this . _getMaximumScale ( ) , scale ) ;
@@ -301,8 +300,6 @@ class Image extends React.Component<ImageComponentProps, ImageComponentState> {
301300 this . _scale . setValue ( Math . min ( this . _getMaximumScale ( ) , scale ) ) ;
302301 this . _setIsZooming ( true ) ;
303302 }
304-
305- this . props . toggleEnableScroll ( false ) ;
306303 }
307304 } ;
308305
@@ -441,7 +438,10 @@ class Image extends React.Component<ImageComponentProps, ImageComponentState> {
441438 return (
442439 < View style = { styles . container } >
443440 < Animated . View style = { backdropStyle } { ...this . _panResponder . panHandlers } />
444- < Animated . View style = { moveObjStyle } { ...this . _panResponder . panHandlers } renderToHardwareTextureAndroid >
441+ < Animated . View
442+ style = { moveObjStyle }
443+ { ...( this . state . isZooming || Platform . OS === 'ios' ? this . _panResponder . panHandlers : { } ) }
444+ renderToHardwareTextureAndroid >
445445 < TapGestureHandler numberOfTaps = { 2 } onActivated = { this . _handleImageZoomInOut } >
446446 < PinchGestureHandler
447447 onGestureEvent = { this . _onPinchGestureEvent }
0 commit comments