UNPKG

translate3d

Version:

A jQuery plugin that transforms HTML-elements depending on the previous transformation with callback.

27 lines (23 loc) 909 B
;(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);