我有一个div,当鼠标上下滚动时,它会水平滚动,当你到达div的末尾时,我希望页面再次垂直滚动。
这就是我现在拥有的
const scrollContainer = document.querySelector(`.horiScroll`);
scrollContainer.addEventListener(`wheel`, (evt) => {
evt.preventDefault();
//check if you are at the end of horizontal scroll here
if (
scrollContainer.scrollWidth - scrollContainer.clientWidth ===
scrollContainer.scrollLeft &&
Math.sign(evt.deltaY) === 1
) {
body.scrollTop += evt.deltaY;
return;
}
//Horizontal scroll code here
scrollContainer.scrollLeft += evt.deltaY;
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
暂无答案!
目前还没有任何答案,快来回答吧!