|
|
@ -25,6 +25,23 @@ |
|
|
|
var scrollableArea; |
|
|
|
var scrollableArea; |
|
|
|
var startedMoving; |
|
|
|
var startedMoving; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Original script from http://davidwalsh.name/vendor-prefix
|
|
|
|
|
|
|
|
var getBrowserCapabilities = (function () { |
|
|
|
|
|
|
|
var styles = window.getComputedStyle(document.documentElement, ''); |
|
|
|
|
|
|
|
var pre = (Array.prototype.slice |
|
|
|
|
|
|
|
.call(styles) |
|
|
|
|
|
|
|
.join('') |
|
|
|
|
|
|
|
.match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o']) |
|
|
|
|
|
|
|
)[1]; |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
prefix: '-' + pre + '-', |
|
|
|
|
|
|
|
transform: pre[0].toUpperCase() + pre.substr(1) + 'Transform' |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var transformPrefix = getBrowserCapabilities.prefix; |
|
|
|
|
|
|
|
var transformProperty = getBrowserCapabilities.transform; |
|
|
|
|
|
|
|
|
|
|
|
var getSlider = function (target) { |
|
|
|
var getSlider = function (target) { |
|
|
|
var i; |
|
|
|
var i; |
|
|
|
var sliders = document.querySelectorAll('.slider > .slide-group'); |
|
|
|
var sliders = document.querySelectorAll('.slider > .slide-group'); |
|
|
@ -39,11 +56,9 @@ |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var getScroll = function () { |
|
|
|
var getScroll = function () { |
|
|
|
if ('webkitTransform' in slider.style) { |
|
|
|
var translate3d = slider.style[transformProperty].match(/translate3d\(([^,]*)/); |
|
|
|
var translate3d = slider.style.webkitTransform.match(/translate3d\(([^,]*)/); |
|
|
|
var ret = translate3d ? translate3d[1] : 0; |
|
|
|
var ret = translate3d ? translate3d[1] : 0; |
|
|
|
return parseInt(ret, 10); |
|
|
|
return parseInt(ret, 10); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var setSlideNumber = function (offset) { |
|
|
|
var setSlideNumber = function (offset) { |
|
|
@ -76,7 +91,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
setSlideNumber(0); |
|
|
|
setSlideNumber(0); |
|
|
|
|
|
|
|
|
|
|
|
slider.style['-webkit-transition-duration'] = 0; |
|
|
|
slider.style[transformPrefix + 'transition-duration'] = 0; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var onTouchMove = function (e) { |
|
|
|
var onTouchMove = function (e) { |
|
|
@ -109,7 +124,7 @@ |
|
|
|
resistance = slideNumber === 0 && deltaX > 0 ? (pageX / sliderWidth) + 1.25 : |
|
|
|
resistance = slideNumber === 0 && deltaX > 0 ? (pageX / sliderWidth) + 1.25 : |
|
|
|
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[transformProperty] = 'translate3d(' + offsetX + 'px,0,0)'; |
|
|
|
|
|
|
|
|
|
|
|
// started moving
|
|
|
|
// started moving
|
|
|
|
startedMoving = true; |
|
|
|
startedMoving = true; |
|
|
@ -127,8 +142,8 @@ |
|
|
|
|
|
|
|
|
|
|
|
offsetX = slideNumber * sliderWidth; |
|
|
|
offsetX = slideNumber * sliderWidth; |
|
|
|
|
|
|
|
|
|
|
|
slider.style['-webkit-transition-duration'] = '.2s'; |
|
|
|
slider.style[transformPrefix + 'transition-duration'] = '.2s'; |
|
|
|
slider.style.webkitTransform = 'translate3d(' + offsetX + 'px,0,0)'; |
|
|
|
slider.style[transformProperty] = 'translate3d(' + offsetX + 'px,0,0)'; |
|
|
|
|
|
|
|
|
|
|
|
e = new CustomEvent('slide', { |
|
|
|
e = new CustomEvent('slide', { |
|
|
|
detail: { slideNumber: Math.abs(slideNumber) }, |
|
|
|
detail: { slideNumber: Math.abs(slideNumber) }, |
|
|
|