html-next / vertical-collection

Infinite Scroll and Occlusion at > 60FPS
https://html-next.github.io/vertical-collection/
MIT License
176 stars 77 forks source link

clear scheduled actions after recalculation #391

Closed Atrue closed 1 year ago

Atrue commented 1 year ago

Fixes https://github.com/html-next/vertical-collection/issues/317. Similar https://github.com/html-next/vertical-collection/pull/359 but using another approach + tests

Scheduled actions as the name says are fired with delay after the render is finished. They are going through the sync queue (scheduleUpdate method) and the measure queue (update method) in the radar class and setTimeout (_scheduleSendAction method) in the component. So there is some gap after the render is finished and before the event is actually fired when the items argument can be changed and the event will be fired with an exception. The scheduled actions include the event and index of the item, but due to timeout, the actual item may not exist for this index.

Clear the timeout and the queue before scheduling a new update after recalculation to omit these outdated events and fire only the new actual events

andreyfel commented 1 year ago

@mixonic will you be able to cut a release with this fix? Thanks!

mixonic commented 1 year ago

Of course. I'm running it through some full-stack checks. See https://github.com/Addepar/ember-table/pull/969. I'm also running it on an app at Addepar as a sanity check :+1:

mixonic commented 1 year ago

Now released in 4.0.1 :tada: Thank you @Atrue and team.

andreyfel commented 1 year ago

Thanks @mixonic!