简体   繁体   English

平滑滚动不提供 React.JS 功能(尝试了多个包)

[英]Smooth scroll gives no functionality with React.JS (tried multiple packages)

I was wondering if anyone can point me in the right direction in relation to enabling smooth scrolling features whilst using React & Webpack.我想知道是否有人可以在使用 React 和 Webpack 的同时启用平滑滚动功能方面为我指明正确的方向。

To be specific my app foundation is using: https://github.com/truffle-box/react-box具体来说,我的应用程序基础正在使用: https : //github.com/truffle-box/react-box

Packages attempted:尝试的软件包:

https://github.com/fisshy/react-scroll https://github.com/fisshy/react-scroll

https://github.com/iamdustan/smoothscroll https://github.com/iamdustan/smoothscroll

https://github.com/ganderzz/react-scroll-to https://github.com/ganderzz/react-scroll-to

https://github.com/flyingant/react-scroll-to-component https://github.com/flyingant/react-scroll-to-component

The only functioning scrolling feature I found that I discovered is:我发现的唯一可用的滚动功能是:

var element = document.getElementsByClassName('test')[0];

element.scrollIntoView();

Which works but is not a smooth scrolling function there is parameters to add that do make this a smooth operation but are not supported on chrome.哪个有效,但不是平滑的滚动功能,需要添加一些参数,使其成为平滑的操作,但在 chrome 上不受支持。

element.scrollIntoView({behavior: "smooth"});

I get ZERO response or console outputs when I implement this variation.当我实现这个变化时,我得到零响应或控制台输出。 If someone could help me I'd highly appreciate it.如果有人可以帮助我,我将不胜感激。

Regards.问候。

Seem's that chrome has updated the method and it now works.似乎 chrome 已经更新了方法,现在可以使用了。

var element = document.getElementsByClassName('test')[0];
element.scrollIntoView({behavior: "smooth"});

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

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