Skip to content

Commit 1357fd4

Browse files
committed
wesbos#13 my way
1 parent fc02b58 commit 1357fd4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

13 - Slide in on Scroll/index-START.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ <h1>Slide in on Scroll</h1>
5858
};
5959
}
6060

61+
let last_known_scroll_position = window.scrollY;
62+
let imgs = document.querySelectorAll('img');
63+
window.addEventListener('scroll', () => {
64+
last_known_scroll_position = window.scrollY;
65+
for (let i = 0; i < imgs.length; i++) {
66+
if (last_known_scroll_position >= imgs[i].y) {
67+
imgs[i].classList.add('active');
68+
}
69+
}
70+
})
6171
</script>
6272

6373
<style>

0 commit comments

Comments
 (0)