Skip to content

Commit bd6a46b

Browse files
authored
Merge pull request #28 from satyam-seth-learnings/scroll-watcher
Add scroll watcher demo
2 parents dc7da83 + bd58e4a commit bd6a46b

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

Scroll Watcher/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- [Reference Video](https://youtu.be/UmzFk68Bwdk?si=NsQhg4apKcF0rYhs)
2+
3+
- [animation-timeline MDN Link](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-timeline)
4+
5+
- [animation-timeline Polyfill Link](https://github.com/flackr/scroll-timeline)

Scroll Watcher/demo.html

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<link rel="stylesheet" href="style.css">
9+
<title>Scroll Watcher</title>
10+
<script src="https://flackr.github.io/scroll-timeline/dist/scroll-timeline.js"></script>
11+
</head>
12+
13+
<body>
14+
<div class="progress"></div>
15+
<section>
16+
<p>Section 1</p>
17+
</section>
18+
<section>
19+
<p>Section 2</p>
20+
</section>
21+
<section>
22+
<p>Section 3</p>
23+
</section>
24+
<section>
25+
<p>Section 4</p>
26+
</section>
27+
<section>
28+
<p>Section 5</p>
29+
</section>
30+
</body>
31+
32+
</html>

Scroll Watcher/style.css

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
* {
2+
margin: 0;
3+
padding: 0;
4+
box-sizing: border-box;
5+
}
6+
7+
body {
8+
scroll-behavior: smooth;
9+
font-family: Verdana, Geneva, Tahoma, sans-serif;
10+
}
11+
12+
section {
13+
min-height: 100dvh;
14+
display: grid;
15+
place-items: center;
16+
}
17+
18+
section:nth-child(odd) {
19+
background-color: blueviolet;
20+
}
21+
22+
section:nth-child(even) {
23+
background-color: coral;
24+
}
25+
26+
p {
27+
color: #ddd;
28+
font-size: 3em;
29+
font-weight: bolder;
30+
}
31+
32+
.progress {
33+
width: 100%;
34+
height: 10px;
35+
position: fixed;
36+
top: 0;
37+
z-index: 100;
38+
background-color: lime;
39+
scale: 0 1;
40+
animation: scroll-watcher linear;
41+
animation-timeline: scroll();
42+
transform-origin: left;
43+
}
44+
45+
@keyframes scroll-watcher {
46+
to {
47+
scale: 1 1;
48+
}
49+
}

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<a href="./Image Sprites/demo.html">Image Sprites</a>
5656
<a href="./BEM(Block, Element Modifier)/demo.html">BEM(Block, Element Modifier)</a>
5757
<a href="./3D animation/demo.html">3D Animation</a>
58+
<a href="./Scroll Watcher/demo.html">Scroll Watcher</a>
5859
</body>
5960

6061
</html>

0 commit comments

Comments
 (0)