vendor/assets/javascripts/jquery.lory.js in lory-rails-0.2.0 vs vendor/assets/javascripts/jquery.lory.js in lory-rails-0.2.1

- old
+ new

@@ -241,10 +241,17 @@ } } } /** + * returns an element's width + */ + function elementWidth(element) { + return element.getBoundingClientRect().width || element.offsetWidth; + } + + /** * slidefunction called by prev, next & touchend * * determine nextIndex and slide to next postion * under restrictions of the defined options * @@ -446,16 +453,16 @@ rewindOnResize = _options5.rewindOnResize, classNameActiveSlide = _options5.classNameActiveSlide, initialIndex = _options5.initialIndex; - slidesWidth = slideContainer.getBoundingClientRect().width || slideContainer.offsetWidth; - frameWidth = frame.getBoundingClientRect().width || frame.offsetWidth; + slidesWidth = elementWidth(slideContainer); + frameWidth = elementWidth(frame); if (frameWidth === slidesWidth) { slidesWidth = slides.reduce(function (previousValue, slide) { - return previousValue + slide.getBoundingClientRect().width || slide.offsetWidth; + return previousValue + elementWidth(slide); }, 0); } if (rewindOnResize) { index = initialIndex; @@ -685,14 +692,16 @@ event.preventDefault(); } } function onResize(event) { - reset(); + if (frameWidth !== elementWidth(frame)) { + reset(); - dispatchSliderEvent('on', 'resize', { - event: event - }); + dispatchSliderEvent('on', 'resize', { + event: event + }); + } } // trigger initial setup setup(); \ No newline at end of file