metafizzy / flickity

:leaves: Touch, responsive, flickable carousels
https://flickity.metafizzy.co
7.54k stars 602 forks source link

lazyLoad loading too many images #1245

Open patricekaufmann opened 2 years ago

patricekaufmann commented 2 years ago

The issue originates from RR https://github.com/metafizzy/flickity/pull/158

While this is more than 7 years ago, this change actually leads to weird behaviour in the following scenario:

Settings: 100% slide width, lazyLoad: 1 and wrapAround: false Slide Amount: 3

I would expect to always only lazyload the next element in this case, however with that change in the PR it leads to preloading all images if there are 3 slides total since 1 + (1 * 2) >= 3.

desandro commented 1 year ago

I'm not seeing 3 slides loaded in this example. Could you provide a test case showing the bug?

patricekaufmann commented 1 year ago

Thanks for looking into this! I modified your example by removing the fourth item. The bug happens when there are exactly three items:

https://codepen.io/patricekaufmann/pen/XWBaBKj

Network tab showing 3 images loaded on page load:

msedge_HHUqdEuhPz

desandro commented 1 year ago

aaaaah good catch. Thanks for that. I'll have a fix in the next release!