Is there a way to trigger a scroll wheel event with an arbitrary delta?
Just like jQuery does with 'click' like:
$('#selector').trigger('click');
I need something like that just with an scrollwheel like:
$('#selector').trigger('DOMMouseScroll',{delta: -650});
//or mousewheel for other browsers
I can't do anything like 'fake it' with CSS trickery, I need to trigger the actual native (or as close as possible) event.
Check this below code to trigger a scrolldown
let wheelEvent = new WheelEvent('wheel', {
deltaY: 1,
deltaMode: 1
});
document.getElementById('selector').dispatchEvent(wheelEvent);
<div id="selector"></div>
Reference: https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With