akiran / akiran/react-slick

Trigger slider to recalculate slide widths after image loaded

Offen
#1,900 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
11.9k
Forks
2.1k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

I'm looking for a way to get the slider to recalculate the slide widths after the images have loaded.

We are creating the contents of the slider based on results from an AJAX call, but the slide width is being calculated at `0px` because it happens before the image has finished loading.

If we listen for the image loaded event and then set the slides width to `auto` it forces the slider to recalculate the slides width, but not every time. Sometimes we are left with the width `auto` and this causes issues with the slides breaking onto a new row inside the slide.

Is there any reliable way to get the slider to recalculate the slides widths after an event?

Also mentioned in this issue: https://github.com/akiran/react-slick/issues/1884#issuecomment-699716131

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.