Last active
August 29, 2015 14:11
-
-
Save apertureless/772e8c32b7e04d30b69f to your computer and use it in GitHub Desktop.
Responsive iFrame js
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
jQuery(document).ready(function( $ ){ | |
function responsiveFrame() { | |
$( 'iframe' ).each(function(){ | |
var fh = $( this ).height(); | |
var fw = $( this ).width(); | |
var fp = $( this ).parent().width(); | |
var fpw = fp/fw; | |
var fpwh = Math.round( fh*fpw ); | |
$( this ).css({ | |
'width': fp, | |
'height': fpwh, | |
}); | |
}); | |
} | |
responsiveFrame(); | |
$(window).resize(function(){ | |
responsiveFrame(); | |
}); | |
var watch_body = $( 'body' ); | |
var body_height = watch_body.innerHeight(); | |
window.setInternal(function(){ | |
var new_height = watch_body.innerHeight(); | |
if ( new_height != body_height ) { | |
body_height = new_height; | |
responsiveFrame(); | |
} | |
}, 200); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment