Skip to content

Commit 62dba42

Browse files
committed
Complete Day 13 - Slide in on Scroll
1 parent 7bf2b79 commit 62dba42

2 files changed

Lines changed: 12 additions & 135 deletions

File tree

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

Lines changed: 0 additions & 124 deletions
This file was deleted.

13 - Slide in on Scroll/index-FINISHED.html renamed to 13 - Slide in on Scroll/index.html

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>Document</title>
6-
<link rel="icon" href="https://fav.farm/" />
6+
<link rel="icon" href="https://fav.farm/🔥" />
77
</head>
88
<body>
99

@@ -44,7 +44,7 @@ <h1>Slide in on Scroll</h1>
4444
</div>
4545

4646
<script>
47-
function debounce(func, wait = 20, immediate = true) {
47+
function debounce(func, wait = 6, immediate = true) {
4848
var timeout;
4949
return function() {
5050
var context = this, args = arguments;
@@ -57,24 +57,24 @@ <h1>Slide in on Scroll</h1>
5757
timeout = setTimeout(later, wait);
5858
if (callNow) func.apply(context, args);
5959
};
60-
};
60+
}
6161

6262
const sliderImages = document.querySelectorAll('.slide-in');
6363

64-
function checkSlide() {
64+
function checkSlide(e) {
6565
sliderImages.forEach(sliderImage => {
6666
// half way through the image
6767
const slideInAt = (window.scrollY + window.innerHeight) - sliderImage.height / 2;
6868
// bottom of the image
6969
const imageBottom = sliderImage.offsetTop + sliderImage.height;
7070
const isHalfShown = slideInAt > sliderImage.offsetTop;
71-
const isNotScrolledPast = window.scrollY < imageBottom;
72-
if (isHalfShown && isNotScrolledPast) {
71+
const isNotScrolledPast = window.scrollY < imageBottom;
72+
if(isHalfShown && isNotScrolledPast){
7373
sliderImage.classList.add('active');
7474
} else {
7575
sliderImage.classList.remove('active');
7676
}
77-
});
77+
})
7878
}
7979

8080
window.addEventListener('scroll', debounce(checkSlide));
@@ -84,7 +84,7 @@ <h1>Slide in on Scroll</h1>
8484
<style>
8585
html {
8686
box-sizing: border-box;
87-
background: #ffc600;
87+
background: #1d3c4a;
8888
font-family: 'helvetica neue';
8989
font-size: 20px;
9090
font-weight: 200;
@@ -100,12 +100,13 @@ <h1>Slide in on Scroll</h1>
100100

101101
h1 {
102102
margin-top: 0;
103+
color:#1d3c4a;
103104
}
104105

105106
.site-wrap {
106107
max-width: 700px;
107108
margin: 100px auto;
108-
background: white;
109+
background: #ebf8fe;
109110
padding: 40px;
110111
text-align: justify;
111112
}
@@ -126,11 +127,11 @@ <h1>Slide in on Scroll</h1>
126127
}
127128

128129
.align-left.slide-in {
129-
transform: translateX(-30%) scale(0.95);
130+
transform: translateX(-30%) scale(0.55);
130131
}
131132

132133
.align-right.slide-in {
133-
transform: translateX(30%) scale(0.95);
134+
transform: translateX(30%) scale(0.55);
134135
}
135136

136137
.slide-in.active {

0 commit comments

Comments
 (0)