From 158aee904aea8808722868c2d207a709c9d7a3a8 Mon Sep 17 00:00:00 2001 From: Kit Sunde Date: Mon, 19 May 2014 11:52:04 +0800 Subject: [PATCH] Allow non-slides in the .slide-group. --- js/sliders.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/sliders.js b/js/sliders.js index c42577e..ade6a16 100644 --- a/js/sliders.js +++ b/js/sliders.js @@ -47,10 +47,10 @@ var setSlideNumber = function (offset) { var round = offset ? (deltaX < 0 ? 'ceil' : 'floor') : 'round'; - slideNumber = Math[round](getScroll() / (scrollableArea / slider.children.length)); + slideNumber = Math[round](getScroll() / (scrollableArea / slider.querySelectorAll('.slide').length)); slideNumber += offset; slideNumber = Math.min(slideNumber, 0); - slideNumber = Math.max(-(slider.children.length - 1), slideNumber); + slideNumber = Math.max(-(slider.querySelectorAll('.slide').length - 1), slideNumber); }; var onTouchStart = function (e) { @@ -62,11 +62,11 @@ var firstItem = slider.querySelector('.slide'); - scrollableArea = firstItem.offsetWidth * slider.children.length; + scrollableArea = firstItem.offsetWidth * slider.querySelectorAll('.slide').length; isScrolling = undefined; sliderWidth = slider.offsetWidth; resistance = 1; - lastSlide = -(slider.children.length - 1); + lastSlide = -(slider.querySelectorAll('.slide').length - 1); startTime = +new Date(); pageX = e.touches[0].pageX; pageY = e.touches[0].pageY;