Skip to content

Commit 186e04b

Browse files
committed
13th exercise done
1 parent 5aee57b commit 186e04b

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ <h1>Slide in on Scroll</h1>
6262

6363
function checkSlide(e) {
6464
sliderImages.forEach(sliderImage => {
65-
// half way through the image
66-
const slideInAt = (window.scrollY + window.innerHeight) - sliderImage.height / 2;
67-
// bottom of the image
65+
const slideInAt = (window.scrollY + window.innerHeight) - (sliderImage.height / 2);
6866
const imageBottom = sliderImage.offsetTop + sliderImage.height;
6967
const isHalfShown = slideInAt > sliderImage.offsetTop;
7068
const isNotScrolledPast = window.scrollY < imageBottom;
69+
7170
if (isHalfShown && isNotScrolledPast) {
7271
sliderImage.classList.add('active');
7372
} else {
@@ -77,7 +76,6 @@ <h1>Slide in on Scroll</h1>
7776
}
7877

7978
window.addEventListener('scroll', debounce(checkSlide));
80-
8179
</script>
8280

8381
<style>

0 commit comments

Comments
 (0)