Skip to content

Commit dafc030

Browse files
committed
feat: day 6
1 parent 2e796bc commit dafc030

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

006-scroll animation/index.html

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@
88
</head>
99
<body>
1010
<h1>Scroll to see the animation</h1>
11-
<div class="box"><h2>Content</h2></div>
12-
<div class="box"><h2>Content</h2></div>
13-
<div class="box"><h2>Content</h2></div>
14-
<div class="box"><h2>Content</h2></div>
15-
<div class="box"><h2>Content</h2></div>
16-
<div class="box"><h2>Content</h2></div>
17-
<div class="box"><h2>Content</h2></div>
18-
<div class="box"><h2>Content</h2></div>
19-
<div class="box"><h2>Content</h2></div>
20-
<div class="box"><h2>Content</h2></div>
21-
<div class="box"><h2>Content</h2></div>
22-
<div class="box"><h2>Content</h2></div>
11+
<!-- Add Different Content to Boxes -->
12+
<div class="box"><h2>Introduction</h2></div>
13+
<div class="box"><h2>Getting Started</h2></div>
14+
<div class="box"><h2>Basic Concepts</h2></div>
15+
<div class="box"><h2>Advanced Features</h2></div>
16+
<div class="box"><h2>Best Practices</h2></div>
17+
<div class="box"><h2>Common Pitfalls</h2></div>
18+
<div class="box"><h2>Troubleshooting</h2></div>
19+
<div class="box"><h2>Performance Tips</h2></div>
20+
<div class="box"><h2>Examples</h2></div>
21+
<div class="box"><h2>Resources</h2></div>
22+
<div class="box"><h2>Community</h2></div>
23+
<div class="box"><h2>Conclusion</h2></div>
2324
<script src="script.js"></script>
2425
</body>
2526
</html>

006-scroll animation/script.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const boxes = document.querySelectorAll(".box");
22

33
const checkBoxes = () => {
4-
const triggerBottom = (window.innerHeight / 5) * 4;
4+
// Adjust Scroll Trigger Point
5+
const triggerBottom = (window.innerHeight / 5) * 3.9;
56
boxes.forEach((box) => {
67
const boxTop = box.getBoundingClientRect().top;
78
if (boxTop < triggerBottom) box.classList.add("show");

006-scroll animation/style.css

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,23 @@ h1 {
3030
margin: 10px;
3131
border-radius: 10px;
3232
box-shadow: 2px 4px 5px rgba(0, 0, 0, 0.3);
33-
transform: translateX(400%);
34-
transition: transform 0.4s ease;
33+
/* Change Animation Direction for All Boxes */
34+
transform: translateY(100%);
35+
/* Create a Fade In Animation */
36+
opacity: 0;
37+
/* transition: transform 0.4s ease; */
38+
transition: transform 0.4s ease, opacity 0.4s ease;
3539
}
3640

37-
.box:nth-of-type(even) {
38-
transform: translateX(-400%);
39-
}
41+
/* .box:nth-of-type(even) {
42+
transform: translateX(400%);
43+
} */
4044

4145
.box.show {
42-
transform: translateX(0);
46+
transform: translateY(0);
47+
/* Change Box Background Color on Show */
48+
background-color: #34113f;
49+
opacity: 1;
4350
}
4451

4552
.box h2 {

0 commit comments

Comments
 (0)