我使用perfect-scrollbar https://github.com/mdbootstrap/perfect-scrollbar来定制滚动条。仅当鼠标悬停在容器上时,滚动条才可见。
如何在滚动事件中仅显示条,并在滚动结束时将其隐藏?
发布于 2021-11-03 08:26:04
您可以尝试使用javascript onscroll()函数。试试这样的东西-
<html>
<body onscroll="bodyScroll();">
<script language="javascript">
var scrollTimer = -1;
function bodyScroll() {
document.body.style.backgroundColor = "white";
if (scrollTimer != -1)
clearTimeout(scrollTimer);
scrollTimer = window.setTimeout("scrollFinished()", 500);
}
function scrollFinished() {
document.body.style.backgroundColor = "red";
}
</script>
<div style="height:2000px;">
Scroll the page down. The page will turn red when the scrolling has finished.
</div>
</body>
</html>
这段代码来自另一个堆栈问题-- How do I know when I've stopped scrolling?
链接到js- https://www.w3schools.com/jsref/event_onscroll.asp中的onscroll()事件
https://stackoverflow.com/questions/69820535
复制相似问题