sveltejs / svelte-virtual-list

A virtual list component for Svelte apps
https://svelte.dev/repl/f78ddd84a1a540a9a40512df39ef751b
Other
688 stars 58 forks source link

IE11 - error thrown #39

Open crisward opened 4 years ago

crisward commented 4 years ago

https://github.com/sveltejs/svelte-virtual-list/blob/master/VirtualList.svelte#L122

.scrollTo only exists on window in IE. So this cause an error to be thrown.

https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo

This can be fixed by adding a check first

viewport.scrollTo && viewport.scrollTo(0, scrollTop + d);

Apart from that, works fine in IE. If you'd prefer this in the form of a pull request, let me know.

crisward commented 4 years ago

BTW looks like it could be just as easy to use scrollTop instead.

https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop