We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 97bd583 commit aedb1b4Copy full SHA for aedb1b4
1 file changed
13 - Slide in on Scroll/index-START.html
@@ -59,6 +59,24 @@ <h1>Slide in on Scroll</h1>
59
};
60
}
61
62
+ const sliderImages = document.querySelectorAll('.slide-in');
63
+
64
+ function checkSlide(e) {
65
+ sliderImages.forEach(slideImage => {
66
+ const slideInAt = (window.scrollY + window.innerHeight) - slideImage.height / 2;
67
+ const imageBottom = slideImage.offsetTop + slideImage.height;
68
+ const isHalfShown = slideInAt > slideImage.offsetTop;
69
+ const isNotScrolledPast = window.scrollY < imageBottom;
70
+ if(isHalfShown && isNotScrolledPast) {
71
+ slideImage.classList.add('active');
72
+ } else {
73
+ slideImage.classList.remove('active');
74
+ }
75
+ });
76
77
78
+ window.addEventListener('scroll', debounce(checkSlide));
79
80
</script>
81
82
<style>
0 commit comments