The title pretty much describes my objective. Here is the code [works only on WebKit]:
We have two divs, elem1 & elem2. There is also one textbox called logger to display result. elem1 has some text with overflow:scroll.
function eventHandler(e){
var myEvt = new e.constructor(e.type, e);
document.getElementById('elem1').dispatchEvent(myEvt);
}
function elem1MouseScroll(e){
document.getElementById('logger').value='mousescroll on ' + (e.target || e.srcElement).id + ' at (' + e.clientX + ', ' + e.clientY + ')';
}
document.getElementById('elem1').addEventListener('mousewheel', elem1MouseScroll, false);
document.getElementById('elem2').addEventListener('mousewheel', eventHandler, false);
http://jsfiddle.net/s4hwt886/1
[Mouse wheel scroll on blue div is supposed to be forwarded to pink div. The textbox on top shows the result.]
As you can see, even though mousewheel event from elem2 triggers the same on elem1, unfortunately the content inside elem1 does not not actually scroll.
I am quite perplexed. Can anyone help ? You don't have to worry about the not working in Gecko part. The constructor trick does not work in Gecko, so the code will be somewhat larger. That's why I did not include that in the fiddle.
Edit: In Chrome this fiddle works just like I want it to. So I updated the code to support Gecko. Unfortunately Firefox behaves just like Safari. The forwarded event is firing, I can see it in log textbox, but the contents are not scrolling. Here is the updated fiddle: http://jsfiddle.net/s4hwt886/2/
N.B. I want a non-Jquery solution. All other similar threads that I could find deal with Jquery.