File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 288288 var $this = this ,
289289 hDistance = null ,
290290 vDistance = null ,
291+ hDistanceLast = null ,
292+ vDistanceLast = null ,
291293 vSwipe = false ,
292294 hSwipe = false ,
293295 hSwipMinDistance = 50 ,
379381 'transition' : 'transform 0.4s ease'
380382 } ) ;
381383
384+ endCoords = event . originalEvent . targetTouches [ 0 ] ;
385+
386+ vDistanceLast = vDistance ;
387+ vDistance = endCoords . pageY - startCoords . pageY ;
388+
389+ hDistanceLast = hDistance ;
382390 hDistance = endCoords . pageX - startCoords . pageX ;
383391 hDistancePercent = hDistance * 100 / winWidth ;
384392
392400 } ) ;
393401
394402 if ( vSwipe ) {
395- if ( slider . css ( 'opacity' ) <= 0.5 ) {
403+ if ( slider . css ( 'opacity' ) <= 0.5 && abs ( vDistance ) >= abs ( vDistanceLast ) ) {
396404 var vOffset = vDistance > 0 ? slider . height ( ) : - slider . height ( ) ;
397405 slider . animate ( { top : vOffset + 'px' , 'opacity' : 0 } ,
398406 300 ,
406414 vSwipe = false ;
407415 return ;
408416 } else if ( hSwipe ) {
409- if ( hDistance >= hSwipMinDistance ) {
417+ if ( hDistance >= hSwipMinDistance && hDistance >= hDistanceLast ) {
410418 // swipeLeft
411419 $this . getPrev ( ) ;
412- } else if ( hDistance <= - hSwipMinDistance ) {
420+ } else if ( hDistance <= - hSwipMinDistance && hDistance <= hDistanceLast ) {
413421 // swipeRight
414422 $this . getNext ( ) ;
415423 }
You can’t perform that action at this time.
0 commit comments