-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrollgsap.html
More file actions
111 lines (99 loc) · 3.83 KB
/
scrollgsap.html
File metadata and controls
111 lines (99 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*,
*::before,
*::after {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
height: 100vh;
background: #000;
}
.container {
height: 100vh;
overflow: hidden;
display: flex;
color: white;
justify-content: center;
align-items: center;
flex-direction: column;
font-size: 3rem;
word-wrap: nowrap;
gap: -2rem;
white-space: nowrap;
}
.para {
margin-bottom: 5%;
}
.space {
height: 500vh;
}
</style>
</head>
<body>
<div class="space"></div>
<div class="container">
<div class="para">
<p>Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, consectetur Lorem ipsum dolor sit amet, Lorem
ipsum dolor sit amet, consectetur adipisicing elit. Enim,
praesentium.</p>
</div>
<div class="para">
<p>Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, consectetur Lorem ipsum dolor sit amet, Lorem
ipsum dolor sit amet, consectetur adipisicing elit. Enim,
praesentium.</p>
</div>
<div class="para">
<p>Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet, consectetur Lorem ipsum dolor sit amet, Lorem
ipsum dolor sit amet, consectetur adipisicing elit. Enim,
praesentium.</p>
</div>
</div>
<div class="space"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js"
integrity="sha512-7eHRwcbYkK4d9g/6tD/mhkf++eoTHwpNM9woBxtPUBWm67zeAfFC+HrdoE2GanKeocly/VxeLvIqwvCdk7qScg=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/ScrollTrigger.min.js"
integrity="sha512-onMTRKJBKz8M1TnqqDuGBlowlH0ohFzMXYRNebz+yOcc5TQr/zAKsthzhuv0hiyUKEiQEQXEynnXCvNTOk50dg=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<!-- <script src="D:\Kalam\Programming Languages\html\gsap-member\gsap-member\minified\gsap.min.js"></script>
<script src="D:\Kalam\Programming Languages\html\gsap-member\gsap-member\minified\ScrollTrigger.min.js"></script> -->
<script>
const tl = gsap.timeline()
// Fade in text on scroll
let elementsToFadeIn = document.querySelectorAll(".para")
elementsToFadeIn.forEach((element) => {
let offset = element.offsetTop - window.innerHeight / 4
if (window.innerWidth <= 600) {
offset -= 70
} else {
offset += 80
}
tl.to(element, {
duration: 1 + Math.random(), opacity: 1, delay: .5 + Math.random(), scrollTrigger: {
trigger: element,
start: "top center",
toggleActions: "play none none reverse",
scrub: true,
ease: "power1.inOut",
markers: true,
pin: true,
pinSpacing: false,
progress: 0.95,
snap: 1 / 100,
force3D: true,
// id: `fade${elementsToFadeIn.indexOf(element)}`,
// label:`fade ${elementsToFadeIn.indexOf(element)+1} of ${elementsToFadeIn.length}`
},
})
});
</script>
</body>
</html>