What's the best way to implement javascript scroll to element smoothly? or How can I use javascript s

14 Replies, 1782 Views

Honestly, the native `window.scrollTo()` with `behavior: 'smooth'` is fine for most cases, but yeah, it’s not perfect.

If you want delays or custom easing, try this lightweight lib called *zenscroll*. Super easy to set up:
```javascript
import zenscroll from 'zenscroll';
zenscroll.to('#element');
```
Works like a charm and handles edge cases better than vanilla JS.

Messages In This Thread



Users browsing this thread: 1 Guest(s)