Skip to content

Instantly share code, notes, and snippets.

@Artur-
Last active September 19, 2018 08:14
Show Gist options
  • Save Artur-/61b8450cae3e293ddc6d8f98e1c795e1 to your computer and use it in GitHub Desktop.
Save Artur-/61b8450cae3e293ddc6d8f98e1c795e1 to your computer and use it in GitHub Desktop.
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