简体   繁体   English

如何使用javascript制作平滑的滚动效果

[英]How to make a smooth scrolling effect using javascript

I've been looking everywhere and I cannot find an answer for this specific need.我到处寻找,但找不到针对此特定需求的答案。

I want to create a page with this effect - I want the page to scroll down automatically and smoothly to a certain section on the page as soon as the user begins to scroll their mouse.我想创建一个具有这种效果的页面 - 我希望页面在用户开始滚动鼠标时自动平滑地向下滚动到页面上的某个部分。 The problem with using the plugin linked above is that I already have my page designed the way I want, I just want to implement this scrolling effect.使用上面链接的插件的问题是我已经按照我想要的方式设计了我的页面,我只想实现这种滚动效果。 I am by no means a javascript expert - I deal mainly with the layout aspects of web.我绝不是一个 javascript 专家 - 我主要处理 web 的布局方面。 But if someone could show me how I could use javascript to automatically drop to a certain section on the page when the user begins to scroll, I would GREATLY appreciate it.但是,如果有人可以向我展示如何在用户开始滚动时使用 javascript 自动跳转到页面上的某个部分,我将不胜感激。 Thank you!谢谢!

Try Using Nice Scroll尝试使用 Nice Scroll

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.nicescroll/3.7.6/jquery.nicescroll.min.js"></script>

$("#thisdiv").niceScroll({
    mousescrollstep: 40, // scrolling speed with mouse wheel (pixel)
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM