From f497d1cb666fe743688b90b21a5d4e8ebb06ff10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bu=CC=88cker?= Date: Mon, 17 Oct 2016 15:24:31 +0200 Subject: [PATCH] Revert "SW-13129 - Fix article and manufacturer slider rotation" This reverts commit d8ec5b702ac415afc48cad6062a837d18107e12b. This reverts commit 05a4900128d14f7501589872b144fb2c7860b930. This reverts commit 9313aae497b20b7ed587cef6b3d53fe1aedc995c. This reverts commit d1ff27b8d8b3dec286f18c3d44a297e107ee85da. --- .../Mink/features/bootstrap/Page/Homepage.php | 6 +- .../_public/src/js/jquery.product-slider.js | 99 ++----------------- 2 files changed, 10 insertions(+), 95 deletions(-) diff --git a/tests/Mink/features/bootstrap/Page/Homepage.php b/tests/Mink/features/bootstrap/Page/Homepage.php index 20df813feaf..a7d0101fe9b 100644 --- a/tests/Mink/features/bootstrap/Page/Homepage.php +++ b/tests/Mink/features/bootstrap/Page/Homepage.php @@ -265,7 +265,7 @@ public function checkSlider(SliderElement $slider, array $slides) { $properties = array_keys(current($slides)); - $sliderSlides = array_slice($slider->getSlides($properties), 0, count($slides)); + $sliderSlides = $slider->getSlides($properties); $result = Helper::compareArrays($sliderSlides, $slides); @@ -275,8 +275,8 @@ public function checkSlider(SliderElement $slider, array $slides) $message = [ sprintf('The slides have a different %s!', $result['key']), - 'Given: ' . print_r($result['value'], true), - 'Expected: ' . print_r($result['value2'], true) + 'Given: ' . $result['value'], + 'Expected: ' . $result['value2'] ]; Helper::throwException($message); diff --git a/themes/Frontend/Responsive/frontend/_public/src/js/jquery.product-slider.js b/themes/Frontend/Responsive/frontend/_public/src/js/jquery.product-slider.js index 418aed85c31..c1d843b1d4f 100644 --- a/themes/Frontend/Responsive/frontend/_public/src/js/jquery.product-slider.js +++ b/themes/Frontend/Responsive/frontend/_public/src/js/jquery.product-slider.js @@ -302,9 +302,6 @@ me.bufferedCall = false; me.initialized = false; - me.scrollingReachedEndOfItems = false; - me.totalUniqueItems = 0; - me.isLoading = false; me.isAnimating = false; @@ -346,16 +343,6 @@ me.trackItems(); me.setSizes(); - /** - * If the page size gets bigger we have to copy more items for infinite sliding. - */ - var copyCount = me.itemsCount - me.totalUniqueItems, - copySize = me.itemsPerPage + me.opts.itemsPerSlide; - - if (me.totalUniqueItems && copySize > copyCount) { - me.cloneItems(copyCount, copySize); - } - /** * Always set back to the first item on update */ @@ -395,10 +382,6 @@ if (me.opts.autoScroll && me.isActive()) me.autoScroll(); if (me.opts.autoSlide && me.isActive()) me.autoSlide(); - if (me.opts.mode !== 'ajax' && me.isActive() && me.$items.length > 0) { - me.initInfiniteSlide(); - } - me.initialized = true; $.publish('plugin/swProductSlider/onInitSlider', [ me ]); @@ -620,13 +603,14 @@ success: function (response) { me.removeLoadingIndicator(); - me.isLoading = false; - me.$container.append(response); - - if (me.itemsCount === me.trackItems()) { - me.initInfiniteSlide(); + if (!response) { + // Prevent infinite loop + return; } + me.isLoading = false; + me.$container.append(response); + me.trackItems(); me.setSizes(); me.trackArrows(); @@ -783,68 +767,13 @@ itemsLeftToLoad = me.opts.ajaxMaxShow - me.itemsCount, loadMoreCount = me.itemsCount - me.itemsPerPage * 2; - if (!me.totalUniqueItems && itemsLeftToLoad === 0) { - me.initInfiniteSlide(); - } - - if (!me.totalUniqueItems && scrolledItems >= loadMoreCount && itemsLeftToLoad > 0) { + if (scrolledItems >= loadMoreCount && itemsLeftToLoad > 0) { me.loadItems(me.itemsCount, Math.min(me.itemsPerPage, itemsLeftToLoad)); } $.publish('plugin/swProductSlider/onScroll', [ me, event ]); }, - /** - * Initializes the slider for infinite sliding. - * The slider will jump to the start position when it reached the end. - * - * @public - * @method initInfiniteSlide - */ - initInfiniteSlide: function () { - var me = this; - - me.cloneItems(0, me.itemsPerPage + me.opts.itemsPerSlide); - - me.totalUniqueItems = me.itemsCount; - me.trackItems(); - - $.publish('plugin/swProductSlider/onInitInfiniteSlide', [ me ]); - }, - - /** - * Clones items in the given index range and appends them to the list. - * Used for infinite sliding. - * - * @public - * @method cloneItems - * @param start - * @param end - */ - cloneItems: function (start, end) { - var me = this, - $copyItems = me.$items.slice(start, end); - - me.$container.append($copyItems.clone()); - - $.publish('plugin/swProductSlider/onCloneItems', [ me, start, end, $copyItems ]); - }, - - /** - * Sets the current position to the relative start position. - * - * @public - * @method resetToStart - */ - resetToStart: function () { - var me = this; - - me.scrollingReachedEndOfItems = false; - me.setPosition((Math.floor(me.currentPosition / me.itemSize) - me.totalUniqueItems) * me.itemSize); - - $.publish('plugin/swProductSlider/onResetToStart', [ me, me.currentPosition ]); - }, - /** * Moves the slider exactly to the next item(s). * Based on the "itemsPerSlide" option. @@ -855,17 +784,9 @@ slideNext: function () { var me = this; - if (me.scrollingReachedEndOfItems) { - me.resetToStart(); - } - me.currentPosition = Math.floor((me.currentPosition + me.itemSize * me.opts.itemsPerSlide) / me.itemSize) * me.itemSize; me.slide(me.currentPosition); - if (me.totalUniqueItems && (me.currentPosition / me.itemSize) >= me.totalUniqueItems) { - me.scrollingReachedEndOfItems = true; - } - $.publish('plugin/swProductSlider/onSlideNext', [ me, me.currentPosition ]); }, @@ -879,8 +800,6 @@ slidePrev: function () { var me = this; - me.scrollingReachedEndOfItems = false; - me.currentPosition = Math.ceil((me.currentPosition - me.itemSize * me.opts.itemsPerSlide) / me.itemSize) * me.itemSize; me.slide(me.currentPosition); @@ -1017,10 +936,6 @@ me.setPosition((direction === 'prev') ? position - speed : position + speed); - if (me.totalUniqueItems && (me.currentPosition / me.itemSize) >= me.totalUniqueItems) { - me.setPosition(0); - } - $.publish('plugin/swProductSlider/onAutoScroll', [ me, me.autoScrollAnimation, scrollDirection, scrollSpeed ]); },