maciekgrzybek / svelte-inview

A Svelte action that monitors an element enters or leaves the viewport.🔥
MIT License
749 stars 23 forks source link

Maybe use `tick()` #31

Closed mustofa-id closed 1 year ago

mustofa-id commented 1 year ago

https://github.com/maciekgrzybek/svelte-inview/blob/b190e9f10753f611a72f02cd0e38671bdab652d0/src/inview.ts#L85-L92

This is likely due to having to wait for the Svelte microtask to complete. I think it's better to use tick().

await tick()
node.dispatchEvent(createEvent<LifecycleEventDetails>('init', { observer, node }));
maciekgrzybek commented 1 year ago

Yes, that sounds like a great idea :) Would you like to add a PR for that? :)

maciekgrzybek commented 1 year ago

Fixed :) Thanks for the solution @mustofa-id