Just wondering if there was any way which you can use javascript in order to have smooth scrolling down a page. I don't mean href's like #section1
ect. I mean actual mouse wheel scrolling. I have looked all over this site and the internet but all I can find is the smooth href scrolling, not smooth mouse wheel scrolling.
Try this: Smooth scrolling demo
You can try something like this:
NOTE: Solution is just rough idea, not crossbrowser at all.
This is surely possible.
I assume you don't want to build it from scratch, so here's a jQuery plugin .
What this plugin does is to listen to mousewheel
and DOMMouseScroll
events, and executes a custom, smooth scroll when they're triggered.
You can easily do it with jquery without any plugin, and you can even decide how much time the scrolling should take.
For instance, if you have an element with id scrollhere
in the point you want to reach, and attach a click listener that will start the animation to a button or a link with id scroll
:
$("#scroll").click(function() {
$('html, body').animate({
scrollTop: $("#scrollHere").offset().top
}, 2000);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.