Skip to content

Instantly share code, notes, and snippets.

@ray-peters
Created March 23, 2016 23:37
Show Gist options
  • Save ray-peters/78748eade62eb4c8505d to your computer and use it in GitHub Desktop.
Save ray-peters/78748eade62eb4c8505d to your computer and use it in GitHub Desktop.
/**
* Overlays iframes to prevent capturing mousewheels while
* scrolling down a long page. Click to destroy.
*
* @author Ray Peters <[email protected]>
*/
;( function(){
$(function(){
$( "iframe" ).each( function(){
addOverlay( $( this ) );
} );
return;
function addOverlay( $iframe ) {
var $newOverlay = buildOverlay( $iframe );
$iframe.parent().append( $newOverlay );
}
function buildOverlay( $iframe ) {
var $newOverlay;
$newOverlay = $( "<div />" );
$newOverlay
.css( {
"display": "block",
"width": "100%",
"opacity": 0,
"position": "absolute",
"top": 0,
"background-color": "#00FF00",
"height": $iframe.height()
} );
$newOverlay.on( "click", function(){
$( this ).remove();
} );
return $newOverlay;
}
} );
} )();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment