-
-
Notifications
You must be signed in to change notification settings - Fork 88
/
index.html
278 lines (240 loc) · 10.2 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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<!-- Use the .htaccess and remove these lines to avoid edge case issues.
More info: h5bp.com/b/378 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Shifty!</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Petrona' rel='stylesheet' type='text/css'>
<style type="text/css" media="screen">
body {
font-family: 'Petrona', Helvetica, Arial, sans-serif;
line-height: 1.7em;
}
pre {
background: #e8e8e8;
font-size: 1.3em;
line-height: 1.4em;
padding: 24px 0px;
}
p {
font-size: 1.2em;
}
a, a:active, a:hover, a:link, a:visited {
color: #a00;
font-weight: bold;
text-decoration: none;
}
a:hover {
color: #f00;
}
#container {
margin: 0px auto 40px;
width: 800px;
}
header {
height: 200px;
color: #aaa;
line-height: 200px;
}
#banner {
font-family: 'Carter One', Helvetica, Arial, sans-serif;
margin: 0px auto;
text-align: center;
}
.segment {
background-color: #f00;
clear: both;
float: left;
left: 0px;
position: relative;
height: 20px;
width: 20px;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
}
#helix-container {
background: #eaeaea;
border: solid 1px #000;
overflow: hidden;
margin: 0px auto 40px;
padding: 50px;
width: 320px;
}
#btnHelixStart {
display: block;
font-family: 'Carter One', Helvetica, Arial, sans-serif;
font-size: 30px;
font-weight: bold;
margin: 15px auto 10px;
height: 60px;
width: 420px;
}
footer {
font-size: 12px;
text-align: center;
}
</style>
<!-- end CSS-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
</head>
<body>
<div id="container">
<header>
<h1 id="banner">Shifty!</h1>
</header>
<ul>
<li><a href="https://raw.github.com/jeremyckahn/shifty/master/dist/shifty.js"><strong>Download <code>shifty.js</code></strong></a>
<li><a href="https://raw.github.com/jeremyckahn/shifty/master/dist/shifty.min.js"><strong>Download <code>shifty.min.js</code></strong></a>
</ul>
<div id="main" role="main">
<a href="https://github.com/jeremyckahn/shifty"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/30f550e0d38ceb6ef5b81500c64d970b7fb0f028/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub"></a>
<p>Shifty is a tweening engine built in JavaScript. It is designed to fit any number of tweening needs. Features include:</p>
<ul>
<li>Speed - Shifty is optimized for performance.</li>
<li>Works well as the base function in a prototype chain.</li>
<li>Modular, extensible architecture allows you to use only the Shifty components you need.</li>
<li>Small download: Full library (with all extensions) is about 3K minified and gzipped. The core of the library (<code><a href="https://github.com/jeremyckahn/shifty/blob/master/src/shifty.core.js" target="_blank">shifty.core.js</a></code>) is just under 1.5K.</li>
</ul>
<p>Shifty is an excellent animation solution for scenarios in which jQuery's <code>animate()</code> function is either unavailable or insufficient. It's particularly effective for creating <code><canvas></code> animations. A common use for Shifty is generating the steps of a Tween, as it is used to do in Joe Lambert's <a href="https://github.com/joelambert/morf" target="_blank">Morf</a> library. Using Shifty in this way would also be very useful in a non-browser environment such as <a href="http://nodejs.org/" target="_blank">Node.js</a>.</p>
<p>Shifty exposes only one function globally: <code>Tweenable()</code>. To create a simple tween, you could have something like this:</p>
<pre>
var myTweenable = new Tweenable();
myTweenable.tween({
from: { 'x': 0 },
to: { 'x': 10 },
duration: 1000,
callback: function () {
alert('Hooray, all done! Final value: ' + this.x);
}
});</pre>
<p>This snippet would start a tween on the <code>x</code> variable from 0 to 1 over one second, and then log a happy message. You could have as many properties in a tween as you'd like.</p>
<p>Shifty can do quite a bit more than this. It gives you play control of a tween (stopping, pausing, and resuming), property access, as well as hooks and filters to customize each tween to your specific needs. In addition to this, there are several extensions that have been built for Shifty. These extensions primarily make Shifty more useful on the DOM by providing support such as CSS units and colors. All of this functionality is documented and demonstrated in the project repo on Github.</p>
<p>A collection of Robert Penner's easing formulas have been adapted for use with Shifty and are included in the standard download.</p>
<p>Please fork, use and contribute to Shifty! It is distributed under the MIT License, and experimentation is encouraged. If you find a bug or have a question about Shifty, please submit it the the <a href="https://github.com/jeremyckahn/shifty/issues" target="_blank">Github issue tracker</a>.</p>
<p>Here's another example of Shifty in use. Now get tweening!</p>
<button id="btnHelixStart">Go go helix!</button>
<div id="helix-container">
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
<span class="segment"></span>
</div>
</div>
<footer>
Shifty is an open source project by <a href="https://github.com/jeremyckahn">Jeremy Kahn</a>. He's a nice guy and likes to make things for your web browser.
</footer>
</div> <!--! end of #container -->
<script type="text/javascript" src="dist/shifty.min.js" charset="utf-8"></script>
<script type="text/javascript" src="src/shifty.simple_ease.js" charset="utf-8"></script>
<script type="text/javascript" src="demos/demo1/shiftme.js" charset="utf-8"></script>
<script type="text/javascript" src="demos/demo2/helix.js" charset="utf-8"></script>
<script type="text/javascript">
(function (global) {
var btnHelixStart
,helixIsInitted
,helixIsRunning;
function animateHeader () {
var header = document.getElementById('banner');
global.shiftyDemo.introInit(header);
setTimeout(function () {
global.shiftyDemo.introGrow(header, 140, function () {
global.shiftyDemo.introFade(header);
});
}, 600);
}
function toggleHelix () {
if (!helixIsInitted) {
helixIsInitted = true;
global.shiftyDemo.helixInit('helix-container');
}
if (helixIsRunning) {
global.shiftyDemo.helixPause();
btnHelixStart.innerHTML = 'Go go helix!';
} else {
global.shiftyDemo.helixPlay();
btnHelixStart.innerHTML = 'Stop stop helix!';
}
helixIsRunning = !helixIsRunning;
}
if (typeof google !== 'undefined') {
google.load("webfont", "1");
google.setOnLoadCallback(function() {
WebFont.load({
google: {
families: [ 'Carter One' ]
}});
animateHeader();
});
} else {
animateHeader();
}
btnHelixStart = document.getElementById('btnHelixStart');
btnHelixStart.addEventListener('click', toggleHelix, true);
helixIsRunning = false;
helixIsInitted = false;
(function () {
// Simple demo dump of all of the formulas
var tweenedVal
,formula;
if (global.console && global.console.log && Tweenable.util.simpleEase) {
console.log('A quick sampling of the different easing formulas:');
// Test and log all of the tweening methods.
for (formula in Tweenable.prototype.formula) {
if (Tweenable.prototype.formula.hasOwnProperty(formula)) {
console.log(formula + ' at 0.5: ' + Tweenable.util.simpleEase(formula, 0.5));
}
}
}
} ());
} (this));
</script>
<!-- end scripts-->
<!-- Prompt IE 6 users to install Chrome Frame. Remove this if you want to support IE 6.
chromium.org/developers/how-tos/chrome-frame-getting-started -->
<!--[if lt IE 7 ]>
<script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
<script>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script>
<![endif]-->
</body>
</html>