Skip to content

Instantly share code, notes, and snippets.

@piyushchauhan2011
Forked from amcdnl/visHack.js
Created August 4, 2017 03:36
Show Gist options
  • Save piyushchauhan2011/9cf9b910da7a9587287ed6bbaa027495 to your computer and use it in GitHub Desktop.
Save piyushchauhan2011/9cf9b910da7a9587287ed6bbaa027495 to your computer and use it in GitHub Desktop.
var element = document.getElementById("panda");
function checkVisibility() {
var bounds = element.getBoundingClientRect(),
visible = bounds.width && bounds.height;
if (visible) {
doMySizeMagic();
} else {
setTimeout(checkVisibility, 100);
}
};
checkVisibility();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment