Switch branches/tags
Find file
Fetching contributors…
Cannot retrieve contributors at this time
66 lines (60 sloc) 2.76 KB
<!DOCTYPE html>
<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="" type="text/javascript" charset="utf-8"></script>
<script src="js/modernizr.js" type="text/javascript" charset="utf-8"></script>
<script src="js/morf.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
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').delegate('li', 'click', function(event){
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, ' '));
<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>
<p>These are the natively supported easing functions, built into WebKit.</p>
<p>These are custom easing functions <em>(thanks to <a href="">Robert Penner</a> &amp; <a href="">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">