Skip to content

Commit

Permalink
add .anim
Browse files Browse the repository at this point in the history
  • Loading branch information
madrobby committed Sep 21, 2010
1 parent 7ad1271 commit 2758676
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Supported element functions:
html('new html'): set the contents of the element(s)
css('css properties'): set styles of the element(s)
append, prepend: like html, but append or prepend to element contents
anim(transform, opacity, duration):
use -webkit-transform/opacity and do an animation

Event handlers ("live" events):

Expand Down
7 changes: 7 additions & 0 deletions examples/anim.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div style="width:100px;height:100px;border:1px solid black">HELLO WORLD</div>

<script src="../zepto.js"></script>

<script>
$('div').anim('rotate(720deg)', 0.5, 10);
</script>
4 changes: 4 additions & 0 deletions zepto.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ $.fn = {
css: function(style){
return $(function(el){ el.style.cssText += ';'+style });
},
anim: function(transform, opacity, dur){
return $.fn.css('-webkit-transition:all '+(dur||0.5)+'s;'+
'-webkit-transform:'+transform+';opacity:'+(opacity===0?0:opacity||1));
},
live: function(event, callback){
var selector = $._;
document.body.addEventListener(event, function(event){
Expand Down

0 comments on commit 2758676

Please sign in to comment.