-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrolltry.html
More file actions
120 lines (103 loc) · 2.94 KB
/
Copy pathscrolltry.html
File metadata and controls
120 lines (103 loc) · 2.94 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
112
113
114
115
116
117
118
119
120
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Growing Image Scroll Effect</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.4/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.4/ScrollTrigger.min.js"></script>
<style>
body {
margin: 0;
padding: 0;
overflow-x: hidden;
}
.section {
width: 100vw;
height: 100vh;
position: relative;
}
.blue {
background-color: #1a237e;
}
.black {
background-color: #000;
}
.growing-image {
position: absolute;
top: 20px;
left: 20px;
width: 100px;
height: 100px;
background-color: #fff;
overflow: hidden;
}
.content {
opacity: 0;
color: white;
padding: 40px;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
img {
width: 100%;
height: 100%;
object-fit: cover;
}
</style>
</head>
<body>
<div class="section blue"></div>
<div class="section black">
<div class="growing-image">
<img src="./public/gridimg1.webp" alt="Growing Image">
</div>
<div class="content">
<h1>Loaded Content</h1>
<p>This appears after the image grows to full size</p>
</div>
</div>
<script>
gsap.registerPlugin(ScrollTrigger);
document.addEventListener('DOMContentLoaded', function () {
const growingImg = document.querySelector('.growing-image');
const content = document.querySelector('.content');
// Set initial state
gsap.set(growingImg, {
width: 100,
height: 100,
top: 0,
left: 0
});
// Create the animation timeline
let tl = gsap.timeline({
scrollTrigger: {
trigger: ".black",
start: "top 120%",
end: "bottom 90%",
scrub: 1,
}
});
// Animation sequence
tl.to(growingImg, {
width: "100vw",
height: "100vh",
top: 0,
left: 0,
duration: 2,
ease: "power2.inOut",
onComplete: function () {
// Show content when animation completes
gsap.to(content, {
opacity: 1,
duration: 0.5
});
}
});
});
</script>
</body>
</html>