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

14 Replies, 1789 Views

If you’re open to libraries, *GSAP’s ScrollToPlugin* is my go-to for buttery smooth scrolling. It handles all the edge cases and lets you add delays, easing, and even scroll horizontally if needed.

```javascript
gsap.to(window, {
scrollTo: "#element",
duration: 1,
ease: "power2.inOut"
});
```
Might be overkill for simple projects, but it’s worth it if you want perfection.

Messages In This Thread



Users browsing this thread: 1 Guest(s)