I have a pretty far-fetched example where you can scroll through a blue singlet, and the event listener will accept the event and send it to another div. I want this to scroll through another div.
This works fine in chrome (version 42.0.2311.135 (64-bit)) with this jsfiddle .
fake.addEventListener('mousescroll', function(e) { var clonedEvent = new e.constructor(e.type, e); container.dispatchEvent(clonedEvent); });
However, just using the Firefox DOMMouseScroll does not work. It throws a TypeError: Illegal constructor. error TypeError: Illegal constructor.
It also does not work if I manually create a new event. Firefox version 37.0.2.
var clonedEvent = document.createEvent("MouseEvents"); clonedEvent.initMouseEvent( ... );
I managed to capture the event and set the scrollTop based on the delta in the event, but this does not use the same animated scroll that happens if you manually scroll the scrollable div.
How can I trigger div-based scroll behavior using JavaScript? I do not want to use jQuery scroll.
source share