Created
May 28, 2021 16:01
-
-
Save yspreen/0a364f9fbd4df07f8bf1fd80b1236402 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
<script> | |
function updateAnimations() { | |
$(".video").each(function () { | |
if ( | |
this.getBoundingClientRect().top <= window.innerHeight && | |
this.getBoundingClientRect().bottom >= 0 | |
) { | |
this.classList.add("scrolled-in"); | |
this.classList.remove("scrolled-out"); | |
} else { | |
this.classList.remove("scrolled-in"); | |
this.classList.add("scrolled-out"); | |
} | |
}); | |
} | |
function main() { | |
$(document).scroll(function () { | |
updateAnimations(); | |
}); | |
$(".video").each(function () { | |
this.onload = updateAnimations; | |
}); | |
updateAnimations(); | |
} | |
$(main); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment