我有一个正在构建的网站,它在桌面上使用水平布局,并在较小的屏幕上切换回原生垂直布局。我正在使用机车滚动,效果很好,但我似乎无法缩小窗口大小。
这是大屏幕的功能
const lscroll = new LocomotiveScroll({
el: document.querySelector('[data-scroll-container]'),
smooth: true,
direction: 'horizontal'
});
在 window.resize 事件中,如果宽度低于移动阈值,我尝试将其销毁并再次调用它,但方向为“垂直”而不是“水平”。
const lscroll = new LocomotiveScroll({
el: document.querySelector('[data-scroll-container]'),
smooth: true,
direction: 'vertical'
});
lscroll.destroy();
lscroll.init();
有任何想法吗?