Skip to content

Commit

Permalink
Merge pull request madrobby#207 from kossnocorp/206_disable_transitio…
Browse files Browse the repository at this point in the history
…n_after_transition_end_event

Disable transition after webkitTransitionEnd event
  • Loading branch information
madrobby committed Jun 27, 2011
2 parents c03bef9 + 4101400 commit 01e5098
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/fx.js
@@ -1,14 +1,21 @@
(function($, undefined){
$.fn.anim = function(properties, duration, ease, callback){
var transforms = [], opacity, key;
var transforms = [], opacity, key, that = this;
for (key in properties)
if (key === 'opacity') opacity = properties[key];
else transforms.push(key + '(' + properties[key] + ')');

var wrappedCallback = function () {
that.css( { '-webkit-transition': 'none' } );
if ( $.isFunction(callback) ) {
callback();
}
};

if (parseFloat(duration) !== 0) {
$.isFunction(callback) && this.one('webkitTransitionEnd', callback);
this.one('webkitTransitionEnd', wrappedCallback);
} else {
setTimeout(callback, 0);
setTimeout(wrappedCallback, 0);
}

return this.css({
Expand Down
1 change: 1 addition & 0 deletions test/fx.html
Expand Up @@ -65,6 +65,7 @@ <h1>Zepto FX unit tests</h1>
t.resume(
function(){
this.assert((new Date().getTime() - start) >= duration);
this.assertEqual('none', $('#callbacktest').get(0).style.webkitTransition);
});
});

Expand Down

0 comments on commit 01e5098

Please sign in to comment.