Reputation: 624
I am making project in SvelteKit, but I'm fairly sure this is going to happen in vanilla all the same. Since that context and working example is important here, Here's minimal reproduction instead of code snippet: Reproduction
The viewport will jump to last snapped element when clicked on accordion item at the bottom of the page. To test:
The viewport will jump to last snapped div.
Any ideas how to prevent that? Firefox is fine.
EDIT: Adding a video of what the issue is as I did not do a great job explaining it. Video
Upvotes: 0
Views: 69
Reputation: 515
That's how css scroll-snapping behaves.
You can prevent the accordion element from being reached by the snapping effect though.
Just adding this to your .svelte file <style>
block solves your snapping issue.
:global(.accordion) {
scroll-snap-stop: always;
}
Upvotes: 0