KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a little "floating tool box" - a div with position:fixed; overflow:auto . Works just fine. But when scrolling inside that box (with the mouse wheel) and reaching the bottom OR top, the parent element "takes over" the "scroll request" : The document behind the tool box scrolls. - Which is annoying and not what the user "asked for". I'm using jQuery and thought I could stop this behaviour with event.stoppropagation(): $("#toolBox").scroll( function(event){ event.stoppropagation() }); It does enter the function, but still, propagation happens anyway (the document scrolls) - It's surprisingly hard to search for this topic on SO (and Google), so I have to ask: How to prevent propagation / bubbling of the scroll-event ? Edit: Working solution thanks to amustill (and Brandon Aaron for the mousewheel-plugin here: https://github.com/brandonaaron/jquery-mousewheel/raw/master/jquery.mousewheel.js $(".ToolPage").bind('mousewheel', function(e, d) var t = $(this); if (d > 0 && t.scrollTop() === 0) { e.preventDefault(); } else { if (d < 0 && (t.scrollTop() == t.get(0).scrollHeight - t.innerHeight())) { e.preventDefault(); } } });
Tags (comma-separated)
Save Edits
Cancel