scrollTo(目标,选项)在移动设备中不起作用.(机车滚动)



我正面临一个奇怪的问题。在台式机上,一切都很好,但当我切换到移动设备时,一些奇怪的事情发生了,不知道为什么。scrollTo(目标,选项)根本不起作用。在桌面水平模式是打开的,对于移动设备,我已经把它关闭了&手机上的平滑也关闭了。

我代码:

const lscroll = new LocomotiveScroll({
el: document.querySelector('[data-scroll-container]'),
smooth: true,
repeat: false,
getDirection: true,
direction: 'horizontal',
tablet: {
smooth: false,
direction: "vertical"
},
smartphone: {
smooth: false,
direction: "vertical"
},
});

我也试过用smooth true移动,但什么也没发生。请帮我一下。TIA

像这样在html文件中使用

<a href="#here" data-scroll-to>
scroll to explore
</a>

..
..
<section  id="here">`enter code here`  </section>

如果在JS中正确初始化机车滚动应该可以工作

最新更新