Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy Loading option loadPrevNext is not working when using fractional numbers for slidesPerView #5712

Closed
4 of 5 tasks
janwidmer opened this issue May 11, 2022 · 0 comments
Closed
4 of 5 tasks

Comments

@janwidmer
Copy link

janwidmer commented May 11, 2022

Reproduction link

https://codesandbox.io/s/swiper-lazy-load-images-forked-1sd1zz

Bug description

When designing carousels, designers often like to show part's of the next slide to give the user a hint, that there is more content to explore. This can be done with swiper by setting the option slidesPerView to e.g. 3.5 as value, which will correctly show 50% of the 4th slide.

So far so good. When taking image lazy loading options into the game (and specifically the option loadPrevNext), a fractional value for slidesPerView seems to break the logic for preloading the previous / next image. You can see that behaviour in the codesandbox. As soon as you change the value for slidesPerView to a full number like 3, preloading the previous / next image works again.

Expected Behavior

When defining a fractional Number for slidesPerView, I expect the next currently fully hidden image to be preloaded.

E.g. slidesPerView set to 3.5. The 5th image is lazy loaded on init and already loaded when I swipe the first time.

Actual Behavior

When defining a fractional Number for slidesPerView, The next currently fully hidden image is only loading when swiping the first time.

E.g. slidesPerView set to 3.5. The 5th image is only loading after I swiped the first time.

Swiper version

8.1.4

Platform/Target and Browser Versions

macOs Chrome 101

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a Swiper issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant