forked from Anemolo/GridToFullscreenAnimations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.html
200 lines (189 loc) · 7.26 KB
/
index2.html
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Grid to Fullscreen Animations | Codrops</title>
<meta name="description" content="A set of thumbnail to fullscreen animations for image grids powered by Three.js" />
<meta name="keywords" content="image grid, animation, fullscreen, webgl, three.js, web design" />
<meta name="author" content="Codrops" />
<link rel="shortcut icon" href="favicon.ico" />
<link rel="stylesheet" href="https://use.typekit.net/ujk6ksk.css" />
<link rel="stylesheet" type="text/css" href="css/base.css" />
<script>document.documentElement.className="js";var supportsCssVars=function(){var a,b=document.createElement("style");return b.innerHTML="root: { --tmp-var: bold; }",document.head.appendChild(b),a=!!(window.CSS&&window.CSS.supports&&window.CSS.supports("font-weight","var(--tmp-var)")),b.parentNode.removeChild(b),a};supportsCssVars()||alert("Please view this demo in a modern browser that supports CSS Variables.");</script>
<!--script src="//tympanus.net/codrops/adpacks/analytics.js"></script-->
</head>
<body class="loading demo-2">
<main>
<div class="frame">
<div class="frame__title-wrap">
<h1 class="frame__title">Grid to Fullscreen Animations</h1>
<div class="frame__links">
<a href="https://tympanus.net/Development/AnimatedImageColumns/">Previous demo</a>
<a href="https://tympanus.net/codrops/?p=40491">Article</a>
<a href="https://github.com/Anemolo/GridToFullscreenAnimations">GitHub</a>
</div>
</div>
<div class="frame__demos">
<span class="frame__demos-title">examples:</span>
<a href="index.html" class="frame__demo">01</a>
<a href="index2.html" class="frame__demo frame__demo--current">02</a>
<a href="index3.html" class="frame__demo">03</a>
<a href="index4.html" class="frame__demo">04</a>
<a href="index5.html" class="frame__demo">05</a>
<a href="index6.html" class="frame__demo">06</a>
</div>
</div>
<!-- /frame -->
<div class="deco">
<div class="deco__text">Connect 2020</div>
<div class="deco__text">Connect 2020</div>
<div class="deco__text">Connect 2020</div>
<div class="deco__text">Connect 2020</div>
<div class="deco__text">Connect 2020</div>
</div>
<div id="app"></div>
<div class="grid" id="itemsWrapper">
<figure class="grid__item">
<img class="grid__item-img" src="img/4.jpg" alt="Some image" />
<img class="grid__item-img grid__item-img--large" src="img/4_large.jpg" />
<figcaption class="grid__item-caption">
<h2 class="grid__item-title">Serenity</h2>
<p class="grid__item-text">
A fan brush can be your best friend. You can do anything your heart can imagine. We'll lay all these little funky little things in there.
</p>
</figcaption>
</figure>
<figure class="grid__item">
<img class="grid__item-img" src="img/5.jpg" alt="Some image" />
<img class="grid__item-img grid__item-img--large" src="img/5_large.jpg" />
<figcaption class="grid__item-caption">
<h2 class="grid__item-title">Steadiness</h2>
<p class="grid__item-text">
We don't want to set these clouds on fire. Let's put some happy trees and bushes back in here.
</p>
</figcaption>
</figure>
<figure class="grid__item">
<img class="grid__item-img" src="img/6.jpg" alt="Some image" />
<img class="grid__item-img grid__item-img--large" src="img/6_large.jpg" />
<figcaption class="grid__item-caption">
<h2 class="grid__item-title">Nature</h2>
<p class="grid__item-text">
Volunteering your time; it pays you and your whole community fantastic dividends. Maybe there's a happy little waterfall happening over here.
</p>
</figcaption>
</figure>
</div>
<div class="fullview">
<div class="fullview__item">
<h2 class="fullview__item-title">Serenity</h2>
</div>
<div class="fullview__item">
<h2 class="fullview__item-title">Steadiness</h2>
</div>
<div class="fullview__item">
<h2 class="fullview__item-title">Nature</h2>
</div>
<button class="fullview__close" aria-label="Close preview"><svg aria-hidden="true" width="24" height="22px" viewBox="0 0 24 22"><path d="M11 9.586L20.192.393l1.415 1.415L12.414 11l9.193 9.192-1.415 1.415L11 12.414l-9.192 9.193-1.415-1.415L9.586 11 .393 1.808 1.808.393 11 9.586z" /></svg></button>
</div>
</main>
<script src="js/imagesloaded.pkgd.min.js"></script>
<script src="js/three.min.js"></script>
<script src="js/TweenLite.min.js"></script>
<script src="js/CSSPlugin.min.js"></script>
<script src="js/EasePack.min.js"></script>
<script src="js/GridToFullscreenEffect.js"></script>
<script src="js/basicDemo.js"></script>
<script>
let currentIndex;
const itemsWrapper = document.getElementById("itemsWrapper");
const thumbs = [...itemsWrapper.querySelectorAll("img.grid__item-img:not(.grid__item-img--large)")];
const fullviewItems = [...document.querySelectorAll(".fullview__item")];
const backToGridCtrl = document.querySelector(".fullview__close");
const transitionEffectDuration = 1;
const transitionEffect = createDemoEffect({
activation: { type: "sinX" },
flipX: false,
timing: {
type: "sections",
sections: 4,
duration: transitionEffectDuration
},
onToFullscreenStart: ({ index }) => {
currentIndex = index;
thumbs[currentIndex].style.opacity = 0;
toggleFullview();
},
onToGridFinish: ({ index, lastIndex }) => {
thumbs[lastIndex].style.opacity = 1;
fullviewItems[currentIndex].classList.remove("fullview__item--current");
},
easings: {
toFullscreen: Cubic.easeInOut,
toGrid: Cubic.easeInOut
}
});
transitionEffect.init();
const toggleFullview = () => {
if (transitionEffect.isFullscreen) {
TweenLite.to(fullviewItems[currentIndex].querySelector(".fullview__item-title"), 0.5, {
ease: Expo.easeOut,
opacity: 0,
x: "-5%"
});
TweenLite.to(backToGridCtrl, 0.5, {
ease: Expo.easeOut,
opacity: 0,
x: "100%"
});
transitionEffect.toGrid();
} else {
fullviewItems[currentIndex].classList.add("fullview__item--current");
TweenLite.to(fullviewItems[currentIndex].querySelector(".fullview__item-title"), 1, {
ease: Expo.easeOut,
startAt: { x: "-5%" },
opacity: 1,
x: "0%",
delay: transitionEffectDuration * 0.5
});
TweenLite.to(backToGridCtrl, 1, {
ease: Expo.easeOut,
startAt: { x: "100%" },
opacity: 1,
x: "0%",
delay: transitionEffectDuration * 0.5
});
}
};
backToGridCtrl.addEventListener("click", () => {
if (transitionEffect.isAnimating) {
return;
}
toggleFullview();
});
// Preload all the images in the page
imagesLoaded(document.querySelectorAll("img"), instance => {
//https://www.techrepublic.com/article/preloading-and-the-javascript-image-object/
document.body.classList.remove("loading");
// Make Images sets for the transition effect
let images = [];
for (var i = 0, imageSet = {}; i < instance.elements.length; i++) {
let image = {
element: instance.elements[i],
image: instance.images[i].isLoaded ? instance.images[i].img : null
};
if (i % 2 === 0) {
imageSet = {};
imageSet.small = image;
}
if (i % 2 === 1) {
imageSet.large = image;
images.push(imageSet);
}
}
transitionEffect.createTextures(images);
});
</script>
</body>
</html>