I am new to javascript and I am trying to make both of these functions run at different times depending on the scroll position but only the first function 'myFunction1' is running. Please help.
<script>
window.onscroll = function redblob() {myFunction()
function myFunction() {
if (document.body.scrollTop > 250 && document.body.scrollTop < 1200 ||
document.documentElement.scrollTop > 250 && document.documentElement.scrollTop < 1200 ) {
document.getElementById("redblob").classList.add('scale-transition');
}
else {
document.getElementById("redblob").classList.remove('scale-transition');
}
}
function myFunction2() {
if (document.body.scrollTop > 1200 && document.body.scrollTop < 1700 ||
document.documentElement.scrollTop > 1200 && document.documentElement.scrollTop < 1700 ) {
document.getElementById("blueblob").classList.add('scale-transition');
}
else {
document.getElementById("blueblob").classList.remove('scale-transition');
}
}
};
</script>
Aucun commentaire:
Enregistrer un commentaire