File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,7 @@ class Swipeable extends React.Component {
117117
118118 const pos = calculatePos ( e , this . swipeable ) ;
119119
120+ // if swipe is under delta and we have not already started to track a swipe: return
120121 if ( pos . absX < delta && pos . absY < delta && ! this . swipeable . swiping ) return ;
121122
122123 if ( stopPropagation ) e . stopPropagation ( ) ;
Original file line number Diff line number Diff line change @@ -205,9 +205,13 @@ describe('Swipeable', () => {
205205
206206 it ( 'does not check delta when swiping in progress' , ( ) => {
207207 const onSwiping = jest . fn ( ) ;
208+ const onSwipedRight = jest . fn ( ) ;
209+ const onSwipedLeft = jest . fn ( ) ;
208210 const wrapper = mount ( (
209211 < Swipeable
210212 onSwiping = { onSwiping }
213+ onSwipedRight = { onSwipedRight }
214+ onSwipedLeft = { onSwipedLeft }
211215 delta = { 40 }
212216 >
213217 < span > Touch Here</ span >
@@ -221,5 +225,7 @@ describe('Swipeable', () => {
221225 touchHere . simulate ( 'touchEnd' , createMoveTouchEventObject ( { x : 80 , y : 100 } ) ) ;
222226
223227 expect ( onSwiping ) . toHaveBeenCalledTimes ( 2 ) ;
228+ expect ( onSwipedLeft ) . toHaveBeenCalledTimes ( 1 ) ;
229+ expect ( onSwipedRight ) . not . toHaveBeenCalled ( ) ;
224230 } ) ;
225231} ) ;
You can’t perform that action at this time.
0 commit comments