Skip to content

lazy prop on swiper slide crashes the carousel and requires manually placing the preloading #8149

@heyitsmass

Description

@heyitsmass

Check that this is really a bug

  • I confirm

Reproduction link

https://codepen.io/heyitsmass/pen/wBWdJyW

Bug description

When using the lazy prop on a SwiperSlide in react, The onLoad attribute for the slide fires before the preloader can render. This results in the preloader never rendering and the core attempting to remove the non-existent element from the DOM.

Expected Behavior

A preloader element is added into the dom when the lazy attribute is applied and a preloader is shown while the image is lazily loading. Once the image loads, the preloader is removed from the DOM.

Actual Behavior

An error and no visible carousel items.

Swiper version

12.0.3

Platform/Target and Browser Versions

Windows,FireFox/147.0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions