I have 2 nested s in my HTML file. When scrolling hits the top or bottom of the Child Div, the Body div starts scrolling as well. To stop that, I have wrote a Function that is called from/on "OnScroll" event from the HTML child so that I can make the scrolling independent for the child and Parent div.
The function that I wrote is as follows:
function selectiveScroll(elementObj)
{
$(elementObj).bind('mousewheel DOMMouseScroll wheel', function(e)
{
var scrollTo = 0;
if (e.type == 'mousewheel')
{
scrollTo = (e.originalEvent.wheelDelta)/(-120);
//alert("mousewheel " + e.originalEvent.wheelDelta + " " + scrollTo );
}
else if (e.type == 'wheel')
{
//alert("wheel " + e.originalEvent.wheelDelta + " " + scrollTo);
scrollTo = (e.originalEvent.wheelDelta * -1)/80;
}
else if (e.type == 'DOMMouseScroll')
{
//alert("DOMMouseScroll " + e.originalEvent.detail);
scrollTo = 40 * e.originalEvent.detail;
}
if (scrollTo)
{
//alert("scrollTo " + scrollTo );
$(this).scrollTop($(this).scrollTop() + scrollTo);
e.preventDefault();
}
});
}
For google Chrome browser this fix worked, but for IE 11, the mouse scroll is restricted to Child and parent, but when the child scrolls, after the initial scrolling hits the end 1 notch in up/down direction of the mouse wheel scrolls all the way up or all the way to bottom of the child.
I understand that: For IE: mousewheel is the event listener For Chrome: Wheel is the event listener For FireFox: DomMouseScroll is the event listener
But I don't understand the first 'If' block "scrollTo = (e.originalEvent.wheelDelta)/(-120);" Part.
How do I control how much scrolling happens with 1 notch of the mouse wheel for IE?
