swiper icon indicating copy to clipboard operation
swiper copied to clipboard

'swiper-button-disabled' class is not applied after initial render

Open AndrewBogdanovTSS opened this issue 4 years ago • 9 comments

This is a (multiple allowed):

  • [x] bug

  • [ ] enhancement

  • [ ] feature-discussion (RFC)

  • Swiper Version: 6.4.1

  • Platform/Target and Browser Versions: All.

  • Live Link or JSFiddle/Codepen or website with isssue: https://codesandbox.io/s/nuxt-swiper-qlvlg?file=/components/Swiper.vue

What you did

Created a swiper with items inside of it. Issue can be reproduced on default settings as well as with slidesPerView: 'auto'. Option watchOverflow is set to true

Expected Behavior

'swiper-button-disabled' should apply to navigation buttons right after initial render of the swiper if the number of slides is smaller than container width

Actual Behavior

'swiper-button-disabled' is not applied after initial render

AndrewBogdanovTSS avatar Dec 16 '20 13:12 AndrewBogdanovTSS

@AndrewBogdanovTSS maybe #3627 related?

vltansky avatar Jan 21 '21 23:01 vltansky

@vltansky yes, it may be related

AndrewBogdanovTSS avatar Jan 23 '21 12:01 AndrewBogdanovTSS

Would be good to see some minimal isolated example, as I can't replicate it with Swiper-Vue or with Swiper-Core

nolimits4web avatar Jan 25 '21 16:01 nolimits4web

@nolimits4web the workaround that worked for me was to update navigation after a delay in nextTick like so:

mounted() {
    this.$nextTick(() => {
        setTimeout(() => this.slider.navigation.update(), 0)
    }
}

so it may be related to the fact that swiper items are passed as a slot content and the moment swiper is trying to calculate it's width items aren't yet fully rendered, but that's just a guess. I don't know if I would be able to provide something more isolated than https://codesandbox.io/s/nuxt-swiper-qlvlg?file=/components/Swiper.vue in the near days. Maybe a bit later when I'll be a bit more free

AndrewBogdanovTSS avatar Jan 28 '21 08:01 AndrewBogdanovTSS

I have the same problem with slidesPerView: 'auto' and watchOverflow: true. Workaround didnt help

adinvadim avatar Aug 04 '21 14:08 adinvadim

Same problem here. Anyone solved?

dangelion avatar Jul 20 '22 17:07 dangelion

My workaround is to use navigation.update() method on afterInit event:

on: {
  afterInit: () => {
   this.navigation.update()
  }
}

However logs will say this.navigation undefined but it works.

Edit: nvm, any undefined variable under afterInit() will make it work.

MJUUrbano avatar Jul 26 '22 19:07 MJUUrbano

These workarounds don't work, is this a recognized bug that will be solved? In that case I could temporary live with it...

dangelion avatar Aug 03 '22 08:08 dangelion

Still experiencing the issue. My workaround for now:

on: {
        afterInit: () => {
          this.slideTo(0); 
      },
}

populationtwo avatar Sep 08 '22 17:09 populationtwo

Still experiencing the issue. My workaround for now:

on: {
        afterInit: () => {
          this.slideTo(0); 
      },
}

this helped, Thank you.

suskull avatar Dec 30 '22 08:12 suskull

can i work on this?

ThisisMS11 avatar Mar 03 '23 12:03 ThisisMS11

I used nuxt-swiper https://nuxt.com/modules/swiper https://github.com/cpreston321/nuxt-swiper

import type { NavigationOptions } from 'swiper/types';

const navigationOption: Ref<NavigationOptions> = ref({
  prevEl: sliderPrevButton,
  nextEl: sliderNextButton,
  disabledClass: 'nav__back--disabled',
});

Can you help for with? How used with solution?

on: {
        afterInit: () => {
          this.slideTo(0); 
      },
}

justMikhail avatar Apr 25 '23 17:04 justMikhail

Still experiencing the issue. My workaround for now:

on: {
        afterInit: () => {
          this.slideTo(0); 
      },
}

I used nuxt-swiper https://nuxt.com/modules/swiper https://github.com/cpreston321/nuxt-swiper

import type { NavigationOptions } from 'swiper/types';

const navigationOption: Ref<NavigationOptions> = ref({
  prevEl: sliderPrevButton,
  nextEl: sliderNextButton,
  disabledClass: 'nav__back--disabled',
});

Can you help for with? How used with solution?

on: {
        afterInit: () => {
          this.slideTo(0); 
      },
}

justMikhail avatar Apr 25 '23 17:04 justMikhail

You can use that:

<Swiper
....
@afterInit="yourFunc" 
...
>

ss-web avatar Jul 05 '23 12:07 ss-web

Issue is closed because of outdated/irrelevant/not actual/needed more information/inactivity.

If this issue is still actual and reproducible for latest version of Swiper, please create new issue and fill the issue template correctly:

  • Clearly describe the issue including steps to reproduce when it is a bug.
  • Make sure you fill in the earliest version that you know has the issue.
  • Provide live link or JSFiddle/Codepen or website with issue

nolimits4web avatar Oct 24 '23 12:10 nolimits4web