Last active
April 8, 2022 06:49
-
-
Save kobitoDevelopment/b972fc029fcbfae77b4ede05a0921d20 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
<p class="one">1</p> | |
<p class="two">2</p> | |
<p class="three">3</p> |
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
const items = document.querySelectorAll("p"); | |
items.forEach(function (elem, index) { | |
elem.classList.add("set"); | |
}); |
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
$(window).on("scroll", function () { | |
$("p").each(function () { | |
if ( | |
$(window).scrollTop() >= | |
$(this).offset().top - $(window).height() + 200 | |
) { | |
$(this).addClass("set"); | |
} else { | |
$(this).removeClass("set"); | |
} | |
}); | |
}); |
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
.one { | |
transition: 1s; | |
transition-delay: 0.5s; | |
opacity: 0; | |
&.set { | |
opacity: 1; | |
} | |
} | |
.two { | |
transition: 1s; | |
transition-delay: 1s; | |
opacity: 0; | |
&.set { | |
opacity: 1; | |
} | |
} | |
.three { | |
transition: 1s; | |
transition-delay: 1.5s; | |
opacity: 0; | |
&.set { | |
opacity: 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment