Created
September 7, 2019 15:56
-
-
Save shangdev/34bc396821e352af0367db608061d981 to your computer and use it in GitHub Desktop.
Revisions
-
shangdev created this gist
Sep 7, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ let overflowX = "auto"; let overflowY = "auto"; let scrollLeft = 0; let scrollTop = 0; let isScrolling; const handleScroll = e => { const element = e.target; window.clearTimeout(isScrolling); isScrolling = window.setTimeout(() => { overflowX = "auto"; overflowY = "auto"; console.log("滚动停止"); }, 250); if (scrollLeft !== element.scrollLeft) { scrollLeft = element.scrollLeft; overflowY = "hidden"; console.log(1); console.log("水平滚动:" + scrollLeft); } if (scrollTop !== element.scrollTop) { scrollTop = element.scrollTop; overflowX = "hidden"; console.log(2); console.log("垂直滚动:" + scrollTop); } };