File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 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 {
117117
118118 const pos = calculatePos ( e , this . swipeable ) ;
119119
120- if ( pos . absX < delta && pos . absY < delta ) return ;
120+ if ( pos . absX < delta && pos . absY < delta && ! this . swipeable . swiping ) return ;
121121
122122 if ( stopPropagation ) e . stopPropagation ( ) ;
123123
Original file line number Diff line number Diff line change @@ -202,4 +202,24 @@ describe('Swipeable', () => {
202202
203203 expect ( preventDefault ) . not . toHaveBeenCalled ( ) ;
204204 } ) ;
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+ } ) ;
205225} ) ;
You can’t perform that action at this time.
0 commit comments