I'm not sure if this would be considered a bug or a feature request. When spinning the carousel with either arrow keys or using the mouse wheel, every item during a spin receives the Active class.

However, when spinning via swiping, the Active class is only applied to the last item that the spin lands on. This ends up breaking styling that is reliant on the active item.

Any help would be greatly appreciated.

Comments

NWOM created an issue. See original summary.

elaman’s picture

Status: Active » Closed (won't fix)

I believe this is Swiper library core bug or they just didn't implement it, because it decreases performance if there are a lot of slides. Here is how you can work around it using Swiper events.

Open slideshow style options in view and find Events section. Paste this to setTransition event:

var cssClass = 'well'; // custom class, that will be added to central slide
var interval = 50; // bigger number == better performance/glitchier graphics

if (transition < interval) return;

var swiper = this;
var IUpdateCenterClass = setInterval(function(){
  if (transition < 0) {
    clearInterval(IUpdateCenterClass);
  } else {
    transition -= interval;

    var containerRect = swiper.$el[0].getBoundingClientRect();
    var containerCenter = containerRect.width / 2 + containerRect.x;
    
    for (slide in swiper.slides) {
      if (typeof swiper.slides[slide] === 'object') {
        var slideRect = swiper.slides[slide].getBoundingClientRect();

        // These calculations won't work with 'vertical' slide
        if (slideRect.x > containerCenter - slideRect.width && slideRect.x <= containerCenter)
          jQuery(swiper.slides[slide]).addClass(cssClass);
        else
          jQuery(swiper.slides[slide]).removeClass(cssClass);
      }
    }
  }
}, interval);

In any case, this issue can't be related to this module. If you'd like you can create an issue ticket at library repository.

nwom’s picture

Category: Bug report » Support request
Status: Closed (won't fix) » Closed (works as designed)

Ah, so it would be a feature request or bug report for the library itself. Thanks for the workaround via the events!

rgnyldz’s picture

Same issue continues for 7.x-4.0

does anyone has a fix like above for the latest version?