Skip to content

Instantly share code, notes, and snippets.

@VoQn
Created April 22, 2011 04:39
Show Gist options
  • Save VoQn/936030 to your computer and use it in GitHub Desktop.
Save VoQn/936030 to your computer and use it in GitHub Desktop.
Generate CSS3 Transition Properties
(function() {
var animateCSS;
animateCSS = function(css, duration, timing_function, delay) {
var animate, browser, obj, property, value, _i, _len, _ref;
if (duration == null) {
duration = '1s';
}
if (timing_function == null) {
timing_function = 'linear';
}
if (delay == null) {
delay = 0;
}
obj = {};
if (css != null) {
animate = '';
for (property in css) {
value = css[property];
obj[property] = value;
if (animate !== '') {
animate += ', ';
}
animate += "" + property + " " + duration + " " + timing_function + " " + delay;
}
if (animate !== '') {
_ref = ['', '-o-', '-moz-', '-webkit-'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
browser = _ref[_i];
obj["" + browser + "transition"] = animate;
}
}
}
return obj;
};
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment