wallop icon indicating copy to clipboard operation
wallop copied to clipboard

Multiple slides animation

Open curdin opened this issue 10 years ago • 14 comments

I've got a setup with multiple sliders on a page all using a slide animation. The issue is that only one actually animates as the other ones seem to get their classes stripped (they still advance but without animation) It seems the issue happens due to the addClass code in WS.goto() or possibly the removeAllHelperSettings.

Do you have any insights on what is happening there?

curdin avatar Oct 20 '15 00:10 curdin

Hey, that's interesting, I will look into it and get back to you. Thanks

peduarte avatar Oct 21 '15 15:10 peduarte

I cannot seem to replicate your issue. I've created this Pen to test it out: http://codepen.io/peduarte/pen/gaoEXz

Can you show me how you're getting this problem?

peduarte avatar Oct 21 '15 15:10 peduarte

Closing as I am unable to replicate your issue, feel free to re open or ask any questions.

peduarte avatar Oct 22 '15 11:10 peduarte

@peduarte Apologies - i was away from a computer for a couple of days. I've updated the codepen to demostrate the issue. If you click the Advance both button you'll see that the left one fails to use a transition. http://codepen.io/anon/pen/xwYLNJ

curdin avatar Oct 22 '15 23:10 curdin

(I seem to be unable to reopen this issue)

curdin avatar Oct 22 '15 23:10 curdin

Wow, amazing find! Will look into it

peduarte avatar Oct 23 '15 09:10 peduarte

Hi guys Did you solve the issue? I have to slider with autoplay and the animations doesn't work properly

afmarchetti avatar Apr 10 '16 16:04 afmarchetti

I found this issue too when using the autoplay example but changing it to autoplay 2 sliders. The classes 'hideprevious' and 'shownext' get added to only 1 of the sliders, not all.

xaddict avatar Apr 14 '16 08:04 xaddict

Hey guys, so sorry for the delay on this. I promise I'll look into it as soon as I can. 🙏

peduarte avatar Apr 14 '16 09:04 peduarte

Here

  // Reset all settings by removing classes and attributes added by goTo() & updateButtonStates()
  WS.removeAllHelperSettings = function () {
    removeClass(this.allItemsArray[this.currentItemIndex], this.options.currentItemClass);
    removeClass($$(this.options.hidePreviousClass)[0], this.options.hidePreviousClass);
    removeClass($$(this.options.hideNextClass)[0], this.options.hideNextClass);
    removeClass($$(this.options.showPreviousClass)[0], this.options.showPreviousClass);
    removeClass($$(this.options.showNextClass)[0], this.options.showNextClass);

    if (!this.buttonPrevious && !this.buttonNext) { return; }

    this.buttonPrevious.removeAttribute('disabled');
    this.buttonNext.removeAttribute('disabled');
  };

and here

  // Helper functions
  function $$(element) {
    if (!element) { return; }
    return document.querySelectorAll('.' + element);
  }

$$ is taking element, but it's just a string of a css class. The if statement in $$ is pointless.

document.querySelectorAll is querying the entire DOM. Also, it will always return an array, empty or not. 0 indexing an empty array returns null.

removeAllHelperSettings is basically just going to town on any DOM element with those classes.

benjaminpkane-zz avatar May 07 '16 01:05 benjaminpkane-zz

I've extended the $$ helper function in order to query within a given container instead of the entire DOM, and fixed the OP issue as well.

Djules avatar Jul 01 '16 12:07 Djules

@Djules Thanks, I'll take a look at the PR. What's the OP issue?

peduarte avatar Jul 13 '16 07:07 peduarte

OP stands for Original Poster, @curdin in this case :)

Djules avatar Jul 13 '16 08:07 Djules

@Djules Ahhh ok! 👍

peduarte avatar Jul 14 '16 10:07 peduarte