Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

70 lines (64 sloc) 3.187 kb
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Morf.js - CSS3 Transitions with custom easing functions</title>
<link rel="stylesheet" href="css/demo.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/modernizr.js" type="text/javascript" charset="utf-8"></script>
<script src="js/shifty.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/src/morf.js" type="text/javascript" charset="utf-8"></script>
<script src="js/src/morf.utils.js" type="text/javascript" charset="utf-8"></script>
<script src="js/src/shifty.fn.scripty2.js" type="text/javascript" charset="utf-8"></script>
<script src="js/src/WebkitCSSMatrix.ext.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(function(){
if(window.WebKitCSSMatrix === undefined || !Modernizr.cssanimations)
alert("Morf.js requires a browser that supports CSS3 Animations & implements the WebKitCSSMatrix object");
// List all the available easing functions
for(var fx in Tweenable.prototype.formula) {
$('ul#custom').prepend('<li>'+fx+'</li>');
}
$('ul').delegate('li', 'click', function(event){
event.preventDefault();
window.t = Morf.transition($('#elem').get(0), {
'-webkit-transform': 'translate'+(Modernizr.csstransforms3d!==undefined?'3d':'')+'('+ (window.toggle?'0px':'598px') +', 0px'+(Modernizr.csstransforms3d!==undefined?',0px':'')+') rotate('+(window.toggle?0:90)+'deg)'
}, {
duration: '1500ms',
timingFunction: $(this).html(),
callback: function () {
if (console && console.log) {
console.log('This got logged in the callback function!');
}
}
});
window.toggle = !window.toggle;
$('section#code').find('textarea').html(t.css.replace(/\t/g, ' '));
});
});
</script>
</head>
<body>
<div id="container">
<h1>CSS3 Transitions with custom easing functions</h1>
<div id="elemcontainer"><div id="elem" style="width: 50px; height: 50px; background: #148a88; border: 1px solid #000"></div></div>
<h2>Native</h2>
<p>These are the natively supported easing functions, built into WebKit.</p>
<ul>
<li>linear</li>
<li>ease</li>
<li>ease-in</li>
<li>ease-out</li>
<li>ease-in-out</li>
</ul>
<h2>Custom</h2>
<p>These are custom easing functions <em>(thanks to <a href="http://www.robertpenner.com/easing/">Robert Penner</a> &amp; <a href="https://raw.github.com/madrobby/scripty2/master/src/effects/transitions/transitions.js">Thomas Fuchs</a>)</em> that can produce much more interesting transitions.</p>
<ul id="custom"></ul>
<h2>Generated Animation CSS</h2>
<p>Internally the custom easing function for the transition is faked using CSS animations. Here is the code that is produced on the fly for the most recent "transition".</p>
<section id="code">
<textarea></textarea>
</section>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.