|
|
@ -23,6 +23,7 @@ |
|
|
|
var slideNumber; |
|
|
|
var slideNumber; |
|
|
|
var isScrolling; |
|
|
|
var isScrolling; |
|
|
|
var scrollableArea; |
|
|
|
var scrollableArea; |
|
|
|
|
|
|
|
var startedMoving; |
|
|
|
|
|
|
|
|
|
|
|
var getSlider = function (target) { |
|
|
|
var getSlider = function (target) { |
|
|
|
var i; |
|
|
|
var i; |
|
|
@ -83,12 +84,17 @@ |
|
|
|
return; // Exit if a pinch || no slider
|
|
|
|
return; // Exit if a pinch || no slider
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// adjust the starting position if we just started to avoid jumpage
|
|
|
|
|
|
|
|
if (!startedMoving) { |
|
|
|
|
|
|
|
pageX += (e.touches[0].pageX - pageX) - 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
deltaX = e.touches[0].pageX - pageX; |
|
|
|
deltaX = e.touches[0].pageX - pageX; |
|
|
|
deltaY = e.touches[0].pageY - pageY; |
|
|
|
deltaY = e.touches[0].pageY - pageY; |
|
|
|
pageX = e.touches[0].pageX; |
|
|
|
pageX = e.touches[0].pageX; |
|
|
|
pageY = e.touches[0].pageY; |
|
|
|
pageY = e.touches[0].pageY; |
|
|
|
|
|
|
|
|
|
|
|
if (typeof isScrolling === 'undefined') { |
|
|
|
if (typeof isScrolling === 'undefined' && startedMoving) { |
|
|
|
isScrolling = Math.abs(deltaY) > Math.abs(deltaX); |
|
|
|
isScrolling = Math.abs(deltaY) > Math.abs(deltaX); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -104,6 +110,9 @@ |
|
|
|
slideNumber === lastSlide && deltaX < 0 ? (Math.abs(pageX) / sliderWidth) + 1.25 : 1; |
|
|
|
slideNumber === lastSlide && deltaX < 0 ? (Math.abs(pageX) / sliderWidth) + 1.25 : 1; |
|
|
|
|
|
|
|
|
|
|
|
slider.style.webkitTransform = 'translate3d(' + offsetX + 'px,0,0)'; |
|
|
|
slider.style.webkitTransform = 'translate3d(' + offsetX + 'px,0,0)'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// started moving
|
|
|
|
|
|
|
|
startedMoving = true; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var onTouchEnd = function (e) { |
|
|
|
var onTouchEnd = function (e) { |
|
|
@ -111,6 +120,9 @@ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// we're done moving
|
|
|
|
|
|
|
|
startedMoving = false; |
|
|
|
|
|
|
|
|
|
|
|
setSlideNumber( |
|
|
|
setSlideNumber( |
|
|
|
(+new Date()) - startTime < 1000 && Math.abs(deltaX) > 15 ? (deltaX < 0 ? -1 : 1) : 0 |
|
|
|
(+new Date()) - startTime < 1000 && Math.abs(deltaX) > 15 ? (deltaX < 0 ? -1 : 1) : 0 |
|
|
|
); |
|
|
|
); |
|
|
|