Created
March 23, 2016 23:37
-
-
Save ray-peters/78748eade62eb4c8505d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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