programmatic smooth scrolling
See original GitHub issue🔎 Usage Questions
Is it possible to programmatically smooth scroll? I’m trying to get a “scroll to top” button working without jumping right back to the top all jittery and ugly -like.
My current code:
$('.go-top').click(function(event) {
event.preventDefault();
let bodyscrollTop = simpleBar.getScrollElement()
bodyscrollTop.scrollTop = 0
// let bodyscrollTopTop = bodyscrollTop.scrollTop
// $('html, body').animate({bodyscrollTopTop: 0}, 300);
})
That works, but jumps immediately back to the top, which isnt great UX…
The commented out portion is how I would expect to be able to do it smoothly, however that doesnt work at all. No Action. It does not generate any error messages either…
I’ve tried the scrollIntoView()
method as well. That doesnt work either.
Is this simply not possible with simplebar or am I missing something?
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
How to Implement Smooth Scrolling With CSS & JavaScript
Learn how to implement smooth scrolling in web pages. Start with a pure CSS solution, then a common jQuery approach.
Read more >Smooth scroll without the use of jQuery - Stack Overflow
Scrolling an element requires changing its scrollTop value over time. For a given point in time, calculate a new scrollTop value. To animate...
Read more >Programmatic scrolling - Vuetify
This method supports several different types of target selectors, and options including smooth scrolling using built-in easing functions.
Read more >Native Smooth Scroll with pure CSS and JS - Lucas Paganini
scroll -behavior: smooth applies a smooth transition when a scroll event is programmatically triggered. I say "programmatically triggered" because it's not going ...
Read more >Smooth Scrolling With JavaScript - Better Programming
A technical look at creating a library from scratch · Detecting the element type · Detect how much to scroll · Triggering the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You could also try
@darkmodeee Codepen See, works like a charm, I find the link tag works better for nested scrollbars as it scrolls both parent and child to get the element into view