-
-
Save max-verem/78bd2c067a6a5c661d0ef441fb135773 to your computer and use it in GitHub Desktop.
Dispatch a mouse wheel event
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 characters
const wheelEvt = document.createEvent('MouseEvents'); | |
wheelEvt.initEvent('wheel', true, true); | |
// Set deltaY depending on wheel up or wheel down | |
wheelEvt.deltaY = +120; | |
// wheelEvt.deltaY = -120; | |
// Pass event to element | |
element.dispatchEvent(wheelEvt); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment