Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save benjaminsinger/92ab2fa1c9700bb9a0f4 to your computer and use it in GitHub Desktop.
Save benjaminsinger/92ab2fa1c9700bb9a0f4 to your computer and use it in GitHub Desktop.
CSS3 And jQuery Animation Helper
// CSS3 Animations Helper
(function($) {
var delay = 0;
$.fn.translate3d = function(translations, speed, easing, complete) {
var opt = $.speed(speed, easing, complete);
opt.easing = opt.easing || 'ease';
translations = $.extend({x: 0, y: 0, z: 0}, translations);
return this.each(function() {
var $this = $(this);
$this.css({
transitionDuration: opt.duration + 'ms',
transitionTimingFunction: opt.easing,
transform: 'translate3d(' + translations.x + 'px, ' + translations.y + 'px, ' + translations.z + 'px)'
});
setTimeout(function() {
$this.css({
transitionDuration: '0s',
transitionTimingFunction: 'ease'
});
opt.complete();
}, opt.duration + (delay || 0));
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment