BigW Consortium Gitlab

animate.js 1.61 KB
Newer Older
1
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-param-reassign, no-void, prefer-template, no-var, new-cap, prefer-arrow-callback, consistent-return, padded-blocks, max-len */
Fatih Acet committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
(function() {
  (function(w) {
    if (w.gl == null) {
      w.gl = {};
    }
    if (gl.animate == null) {
      gl.animate = {};
    }
    gl.animate.animate = function($el, animation, options, done) {
      if ((options != null ? options.cssStart : void 0) != null) {
        $el.css(options.cssStart);
      }
      $el.removeClass(animation + ' animated').addClass(animation + ' animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
        $(this).removeClass(animation + ' animated');
        if (done != null) {
          done();
        }
        if ((options != null ? options.cssEnd : void 0) != null) {
          $el.css(options.cssEnd);
        }
      });
    };
    gl.animate.animateEach = function($els, animation, time, options, done) {
      var dfd;
      dfd = $.Deferred();
      if (!$els.length) {
        dfd.resolve();
      }
      $els.each(function(i) {
        setTimeout((function(_this) {
          return function() {
            var $this;
            $this = $(_this);
            return gl.animate.animate($this, animation, options, function() {
              if (i === $els.length - 1) {
                dfd.resolve();
                if (done != null) {
                  return done();
                }
              }
            });
          };
        })(this), time * i);
      });
      return dfd.promise();
    };
  })(window);

}).call(this);