-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathindex.html
257 lines (215 loc) · 9.15 KB
/
index.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<title>Demo for Alice's Adventures in Wonderland, by Lewis Carroll</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/style.css" media="all" />
<script src="//use.edgefonts.net/cardo:n4.js"></script>
</head>
<body>
<div class="timeline-track js-timeline-track"></div>
<div class="wrapper">
<!-- introduction slide and feature detect message -->
<div class="scene--intro js-scene--intro">
<header>Demo for Alice in Wonderland <span>by Lewis Carroll</span></header>
<p class="description">
<a href="http://blogs.adobe.com/webplatform/2013/10/23/css-shapes-visual-storytelling/" target="_blank">Using CSS Shapes</a> to enhance visual storytelling.
<em class="direction">scroll to begin</em>
</p>
<div class="warning">
<p>
This example demonstrates a cutting-edge feature that the <a href="http://html.adobe.com/webplatform/" target="_blank">Adobe Web Platform Team</a> is working on. To see this feature in action, use a <a href="http://html.adobe.com/webplatform/layout/shapes/browser-support/" target="_blank">browser which supports it</a>, such as <a href="https://www.google.com/intl/en/chrome/browser/">Google Chrome</a> (in older versions you may need to manually <a href="http://html.adobe.com/webplatform/enable/#section-chrome-canary" target="_blank">enable CSS Shapes</a>).
</p>
</div>
<footer>
<a href="http://html.adobe.com" class="adobe-logo" target="_blank">html.adobe.com</a>
<a href="http://ultranoir.com" class="ultranoir-logo" target="_blank">ultranoir.com</a>
</footer>
</div>
<div class="scene--alice js-scene--alice">
<div class="content">
<!-- Using two placeholder floated elements with shape-outside to simulate a shape-inside. Purists, look away! -->
<div class="shape-shim--left"></div>
<div class="shape-shim--right"></div>
<h1 class="js-title">
<span>Alice in Wonderland</span>
</h1>
<p class="js-content">Alice was beginning to get very tired of sitting by her sister on the
bank, and of having nothing to do: once or twice she had peeped into the
book her sister was reading, but it had no pictures or conversations in
it, 'and what is the use of a book,' thought Alice 'without pictures or
conversation?'
<br /><br />So she was considering in her own mind whether the pleasure
of making a daisy-chain would be worth the trouble of getting up and
picking the daisies, when suddenly a White Rabbit with pink eyes ran
close by her.
<br /><br />In another moment down went Alice after it, never once considering how
in the world she was to get out again.
</p>
</div>
</div><!-- end .scene -->
<div class="scene--outro js-scene--outro">
<header>Demo for Alice in Wonderland <span>by Lewis Carroll</span></header>
<p class="description">
<a href="http://blogs.adobe.com/webplatform/2013/10/23/css-shapes-visual-storytelling/" target="_blank">Using CSS Shapes</a> to enhance visual storytelling.
<br><br>
<a href="https://github.com/adobe-webplatform/Demo-for-Alice-s-Adventures-in-Wonderland" target="_blank">View source</a> or
<a href="http://blogs.adobe.com/webplatform/2013/10/23/css-shapes-visual-storytelling/" target="_blank">Learn more</a>
</p>
</header>
</div>
</div><!-- end .wrapper -->
<script>
(function(){
// helpers
var $ = document.querySelector.bind(document);
Node.prototype.on = window.on = function(event, fn){ this.addEventListener(event, fn, false); };
var $sceneIntro = $('.js-scene--intro'),
$sceneOutro = $('.js-scene--outro'),
$sceneAlice = $('.js-scene--alice'),
$elContent = $('.js-content'),
$elTitle = $('.js-title'),
$elTrack = $('.js-timeline-track');
var introBox = $sceneIntro.getBoundingClientRect(),
outroBox = $sceneOutro.getBoundingClientRect(),
aliceBox = $sceneAlice.getBoundingClientRect(),
contentBox = $elContent.getBoundingClientRect(),
titleBox = $elTitle.getBoundingClientRect();
var timeline = [];
// Add intro scene animation to timeline
timeline.push({
min: introBox.top,
max: introBox.height / 4,
freeze: false,
fn: function(progress){
var opacity = 100 - progress;
if (this.freeze){
return;
}
window.requestAnimationFrame(function(){
$sceneIntro.style['-webkit-filter'] = 'opacity(' + opacity + '%)';
$sceneIntro.style['visibility'] = (opacity === 0) ? 'hidden' : 'visible';
// remove this scene after the fade-out
if (progress === 100){
timeline.splice(0,1);
}
});
}
});
// Add Alice scene offset animation to timeline
timeline.push({
// chain after prev animation
min: timeline[timeline.length - 1].max + aliceBox.top,
max: timeline[timeline.length - 1].max + aliceBox.top + aliceBox.height,
freeze: false,
fn: function(progress){
if (this.freeze){
return;
}
var maxOffset = aliceBox.height - window.innerHeight;
var offset = -1 * Math.ceil((maxOffset * progress) / 100);
window.requestAnimationFrame(function(){
var str = 'translate3d(0, ' + offset + 'px, 0)';
$sceneAlice.style['-webkit-transform'] = str;
$sceneAlice.style['transform'] = str;
})
}
});
// Add text offset animation to timeline
timeline.push({
min: timeline[timeline.length - 1].min * 1.4 + contentBox.top,
max: timeline[timeline.length - 1].min * 1.4 + contentBox.top + contentBox.height,
freeze: false,
fn: function(progress){
if (this.freeze){
return;
}
var maxOffset = aliceBox.height - contentBox.top;
var offset = Math.ceil((maxOffset * progress) / 100);
window.requestAnimationFrame(function(){
$elContent.style['margin-top'] = offset + 'px';
})
}
});
// Add fade-to-black animation to timeline
timeline.push({
min: timeline[timeline.length - 1].max * 0.85, // early start
max: timeline[timeline.length - 1].max, // quick transition
freeze: false,
fn: function(progress){
var opacity = progress;
if (this.freeze){
return;
}
window.requestAnimationFrame(function(){
$sceneOutro.style['-webkit-filter'] = 'opacity(' + opacity + '%)';
$sceneOutro.style['visibility'] = (opacity === 0) ? 'hidden' : 'visible';
if (progress === 100){
$sceneOutro.classList.add('complete')
} else {
$sceneOutro.classList.remove('complete')
}
})
}
});
function setup(){
/*
All scenes are `position: fixed`. The .timeline-track el is a placeholder
to create artificial height so the page can be scrolled.
Set .timeline-track height to the maximum extent that needs to be reched
by the scroll.
*/
var max = 0;
timeline.forEach(function(t){
max = (max < t.max) ? t.max : max;
});
$elTrack.style.height = window.innerHeight + Math.round(max) + "px";
// listen to scroll change and trigger animations
window.on('scroll', function(e){
var scrollY = window.scrollY;
// run animations that fit scroll range
timeline.forEach(function(t){
if (t.min < scrollY && scrollY < t.max){
var progress = (scrollY - t.min) / (t.max - t.min);
t.freeze = false;
t.fn.call(t, Math.ceil(progress * 100));
}
/*
'scroll' event granularity is not consistent when scrooling.
Clamp the progress at 0 or 100 and complete any leftover animation,
then freeze until the scroll gets within min/max range again.
*/
if (scrollY > t.max){
t.fn.call(t, 100);
t.freeze = true;
}
if (scrollY < t.min){
t.fn.call(t, 0);
t.freeze = true;
}
})
});
}
// feature detection
['shape-outside'].forEach(function(property){
// check if any variant exists, prefixed or not
var isCapable = ['-webkit-', '-ms-', '-moz-', ''].some(function(prefix){
return (prefix + property) in document.body.style;
})
if (isCapable){
document.documentElement.classList.add('shapes');
setup();
}
});
})();
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-45111913-1', 'adobe-webplatform.github.io');
ga('send', 'pageview');
</script>
</body>
</html>