summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib/utils/animate.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/lib/utils/animate.js')
-rw-r--r--app/assets/javascripts/lib/utils/animate.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/app/assets/javascripts/lib/utils/animate.js b/app/assets/javascripts/lib/utils/animate.js
new file mode 100644
index 00000000000..d36efdabc93
--- /dev/null
+++ b/app/assets/javascripts/lib/utils/animate.js
@@ -0,0 +1,49 @@
+(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);