Skip to content

Instantly share code, notes, and snippets.

@jimyuan
Created September 8, 2017 05:42
Show Gist options
  • Save jimyuan/12ca8bb38e7b6904f7bde1f271d9406a to your computer and use it in GitHub Desktop.
Save jimyuan/12ca8bb38e7b6904f7bde1f271d9406a to your computer and use it in GitHub Desktop.
在页面滚动时禁用 :hover 样式
.disable-hover {
pointer-events: none;
}
window.addEventListener('scroll', () => {
let body = document.body, timer
clearTimeout(timer)
!body.classList.contains('disable-hover') && body.classList.add('disable-hover')
timer = setTimeout(() => {
body.classList.remove('disable-hover')
}, 500);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment