Skip to content

Commit

Permalink
Added ability to run keyframe animations via $.fn.anim
Browse files Browse the repository at this point in the history
  • Loading branch information
kossnocorp committed Aug 8, 2011
1 parent c2b3ea1 commit 8e8f2ca
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions src/fx.js
Expand Up @@ -15,20 +15,35 @@
var transforms = [], cssProperties = {}, key, that = this, wrappedCallback;
if (duration === undefined) duration = 0.5;

for (key in properties)
if (supportedTransforms.indexOf(key)>=0)
transforms.push(key + '(' + properties[key] + ')');
else
cssProperties[key] = properties[key];

if (transforms.length > 0) {
cssProperties['-webkit-transform'] = transforms.join(' ')
}
if (typeof properties === 'string') {

// Keyframe animation

cssProperties['-webkit-animation-name'] = properties;
cssProperties['-webkit-animation-duration'] = duration + 's';

} else {

cssProperties['-webkit-transition'] = 'all ' + duration + 's ' + (ease || '');
// CSS / transition animation

for (key in properties)
if (supportedTransforms.indexOf(key)>=0)
transforms.push(key + '(' + properties[key] + ')');
else
cssProperties[key] = properties[key];

if (transforms.length > 0) {
cssProperties['-webkit-transform'] = transforms.join(' ')
}

cssProperties['-webkit-transition'] = 'all ' + duration + 's ' + (ease || '');
}

wrappedCallback = function(){
$(this).css({'-webkit-transition':'none'});
$(this).css({
'-webkit-transition': 'none',
'-webkit-animation-name': 'none'
});
callback && callback.call(this);
}
if (duration > 0) this.one('webkitTransitionEnd', wrappedCallback);
Expand Down

0 comments on commit 8e8f2ca

Please sign in to comment.