Last active
September 19, 2018 08:14
-
-
Save Artur-/61b8450cae3e293ddc6d8f98e1c795e1 to your computer and use it in GitHub Desktop.
This file contains 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 characters
canScrollElementVertically = (el, direction) => { | |
if (direction > 0) { | |
// Down | |
return ((el.scrollTop + el.offsetHeight) < el.scrollHeight); | |
} else { | |
// Up | |
return (el.scrollTop > 0); | |
} | |
}; | |
document.querySelector("vaadin-dialog-overlay").addEventListener("mousewheel", e => { | |
let composed = e.composedPath(); | |
const bodyPosition = composed.indexOf(document.body); | |
if (bodyPosition != -1) { | |
composed = composed.slice(0, bodyPosition); | |
} | |
if (e.deltaY && !composed.find(el => canScrollElementVertically(el, e.deltaY))) | |
e.preventDefault(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment