-
Notifications
You must be signed in to change notification settings - Fork 51
/
demo.html
66 lines (60 loc) · 2.76 KB
/
demo.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
<!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/morf.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> & <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>