Skip to content

Commit

Permalink
Merge pull request #4121 in SW/shopware from ntr/5.2/revert-article-s…
Browse files Browse the repository at this point in the history
…lider-changes to 5.2

* commit 'f497d1cb666fe743688b90b21a5d4e8ebb06ff10':
  Revert "SW-13129 - Fix article and manufacturer slider rotation"
  • Loading branch information
bcremer committed Oct 17, 2016
2 parents 5b66fc3 + f497d1c commit e55b00e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 95 deletions.
6 changes: 3 additions & 3 deletions tests/Mink/features/bootstrap/Page/Homepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,6 @@
me.bufferedCall = false;
me.initialized = false;

me.scrollingReachedEndOfItems = false;
me.totalUniqueItems = 0;

me.isLoading = false;
me.isAnimating = false;

Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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 ]);
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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.
Expand All @@ -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 ]);
},

Expand All @@ -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);

Expand Down Expand Up @@ -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 ]);
},

Expand Down

0 comments on commit e55b00e

Please sign in to comment.