javascript - How to do slow scrolling like these website are doing - Stack Overflow

There are several websites where I see smooth slow scrolling. I have been looking for plugins for react

There are several websites where I see smooth slow scrolling. I have been looking for plugins for react or vue. I basically want to learn how to do it with vanilla Javascript. Also you can suggest plugins libraries and whatever you want. But I want to know how to do it in pure vanilla js. I want to learn to control scroll speed.

here are the websites:

  1. /

you can tell me what these websites are using also tell me how to do it using pure js.

There are several websites where I see smooth slow scrolling. I have been looking for plugins for react or vue. I basically want to learn how to do it with vanilla Javascript. Also you can suggest plugins libraries and whatever you want. But I want to know how to do it in pure vanilla js. I want to learn to control scroll speed.

here are the websites:

  1. https://nana-asia./
  2. https://pelizzari./en
  3. https://loerarchitecten./en/projects/republica-short-guy

you can tell me what these websites are using also tell me how to do it using pure js.

Share Improve this question asked Apr 20, 2020 at 9:29 Maisha MalihaMaisha Maliha 671 gold badge1 silver badge8 bronze badges 2
  • 1 See this question here: stackoverflow./questions/47011055/… – Enchew Commented Apr 20, 2020 at 9:36
  • I was literaly looking for it for so long – Kabeer Jaffri Commented May 5, 2021 at 21:11
Add a ment  | 

2 Answers 2

Reset to default 2

One approach:

  • Catch the mousewheel and touch events and prevent their orignal behaviour.

  • Detect direction and speed of touch events or scroll amount for mousewheel events

  • Use the event values and map those to the desired scroll level

  • Apply a CSS translate to your page content

If you want the page to scroll smoothly like the first like here is a good plugin https://jokertattoo.co.uk/js/SmoothScroll.js You can mess around with these values till you get a result you want:

 frameRate        : 150, // [Hz]
    animationTime    : 2000, // [px]
    stepSize         : 150, // [px]

and here is a demo of it in action: https://ui-unicorn.co.uk/my-cv/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742416350a4439815.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信