Skip to content

Instantly share code, notes, and snippets.

@ryanzhou7
Created September 23, 2019 18:04
Show Gist options
  • Save ryanzhou7/ba5d67827bd53d918c665bd781bf0712 to your computer and use it in GitHub Desktop.
Save ryanzhou7/ba5d67827bd53d918c665bd781bf0712 to your computer and use it in GitHub Desktop.
<script>
window.iFrameResizer = {
// Allows messages from anywhere
targetOrigin: '*',
// Receiving a message from the parent
onMessage: function(message) {
var messageData = JSON.parse(message);
// Check that this message is for this iframe
if( messageData["id"] === iframeId ){
var sr = messageData["scrollRatio"];
var vr = messageData["verticalDisplayRatio"];
// Trigger animation
if( sr > 0.5 || vr > 0.5 ){
animate();
}
// animateProgressBar(sr);
}
},
}
function animate(){
// do entire animation
}
function animateProgressBar(percentageComplete){
// move from current position to percentageComplete
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment