Created
July 14, 2019 03:24
-
-
Save cbeard87/524c76165f4ed50184dd8787994c7651 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