File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ class Swipeable extends React.Component {
117
117
118
118
const pos = calculatePos ( e , this . swipeable ) ;
119
119
120
- if ( pos . absX < delta && pos . absY < delta ) return ;
120
+ if ( pos . absX < delta && pos . absY < delta && ! this . swipeable . swiping ) return ;
121
121
122
122
if ( stopPropagation ) e . stopPropagation ( ) ;
123
123
Original file line number Diff line number Diff line change @@ -202,4 +202,24 @@ describe('Swipeable', () => {
202
202
203
203
expect ( preventDefault ) . not . toHaveBeenCalled ( ) ;
204
204
} ) ;
205
+
206
+ it ( 'does not check delta when swiping in progress' , ( ) => {
207
+ const onSwiping = jest . fn ( ) ;
208
+ const wrapper = mount ( (
209
+ < Swipeable
210
+ onSwiping = { onSwiping }
211
+ delta = { 40 }
212
+ >
213
+ < span > Touch Here</ span >
214
+ </ Swipeable >
215
+ ) ) ;
216
+
217
+ const touchHere = wrapper . find ( 'span' ) ;
218
+ touchHere . simulate ( 'touchStart' , createStartTouchEventObject ( { x : 100 , y : 100 } ) ) ;
219
+ touchHere . simulate ( 'touchMove' , createMoveTouchEventObject ( { x : 145 , y : 100 } ) ) ;
220
+ touchHere . simulate ( 'touchMove' , createMoveTouchEventObject ( { x : 80 , y : 100 } ) ) ;
221
+ touchHere . simulate ( 'touchEnd' , createMoveTouchEventObject ( { x : 80 , y : 100 } ) ) ;
222
+
223
+ expect ( onSwiping ) . toHaveBeenCalledTimes ( 2 ) ;
224
+ } ) ;
205
225
} ) ;
You can’t perform that action at this time.
0 commit comments