janosh / svelte-toc

Sticky responsive table of contents component
https://janosh.github.io/svelte-toc
MIT License
113 stars 6 forks source link

`keepActiveTocItemInView` should be false by default #52

Closed wentallout closed 9 months ago

wentallout commented 9 months ago

I think this is an unexpected behavior for a ToC and should be disabled by default.

My experience: My ToC keeps automatically moving up and down when I try to scroll it. (I scrolled the ToC, not the page)

janosh commented 9 months ago

I could maybe get behind changing the default but before deciding, could we look into

ToC keeps automatically moving up and down when I try to scroll it.

that should not happen. do you have a link where i can see this in action? maybe there's something like overscroll-behavior at play?

wentallout commented 9 months ago

Here's one of my blog pages that got a buggy ToC (I can't scroll it, it just bounce back): https://wentallout.io.vn/project/reza

Here's my component source code: https://github.com/wentallout/portfolio/blob/master/src/lib/components/blog/CustomToc.svelte

janosh commented 9 months ago

Thanks for the link, that page definitely behaves very oddly. I can only guess that it had to do with the hacky way I used window.setTimeout() to wait for the page scroll to end. Luckily, browser support for the scrollend has jumped from 2% to 71% since I wrote that hack. I'll release what I hope is a fix in 9eaa6a2 shortly.