简体   繁体   English

如何在没有jQuery的情况下更改文档滚动速度

[英]how to change document scroll speed in react without jquery

Is it possible to slow down the scroll speed on certain divs or even just the whole page by using just react? 是否可以通过使用react来降低某些div甚至整个页面的滚动速度?

use refs 使用裁判

Checkout the answer here: How to window.scrollTo() with a smooth effect 在这里签出答案: 如何使用window.scrollTo()产生平滑效果

const btn = document.getElementById('elem');

btn.addEventListener('click', () => window.scrollTo({
  top: 400,
  behavior: 'smooth',
}));

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

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