Reputation: 171
I want to keep the parent from scrolling when using the mouse wheel while focused on the iframe. This only happens when the iframe scrolling limit has been reached. Its so annoying. I have found similar Q&A, but not with the mouse wheel. The scroll bars do not cause the parent to scroll, only the mouse wheel.
Upvotes: 0
Views: 560
Reputation: 427
Alternatively you could set "hover" handler on iframe and toggle body "overflow" property.
Upvotes: 0
Reputation: 427
You could set handler on 'wheel' and 'mousewheel' events in iframe. Inside event handler you should determine direction of wheeling and if top or bottom of page is reached (depends on direction) - cancel default action for event.
jQuery pseudo-code:
$(document).on('wheel mousewheel', function(e) {
var direction = getWheelDirection();
if ( direction == 'bottom' ) {
if ( ...bottom of page reached... ) return false;
} else {
if ( ...top of page reached... ) return false;
}
} );
Upvotes: 1