Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
279 lines (240 sloc) 10.2 KB
<!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>&lt;canvas&gt;</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>
Something went wrong with that request. Please try again.