summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib/utils/animate.js.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/lib/utils/animate.js.coffee')
-rw-r--r--app/assets/javascripts/lib/utils/animate.js.coffee39
1 files changed, 39 insertions, 0 deletions
diff --git a/app/assets/javascripts/lib/utils/animate.js.coffee b/app/assets/javascripts/lib/utils/animate.js.coffee
new file mode 100644
index 00000000000..ec3b44d6126
--- /dev/null
+++ b/app/assets/javascripts/lib/utils/animate.js.coffee
@@ -0,0 +1,39 @@
+((w) ->
+ if not w.gl? then w.gl = {}
+ if not gl.animate? then gl.animate = {}
+
+ gl.animate.animate = ($el, animation, options, done) ->
+ if options?.cssStart?
+ $el.css(options.cssStart)
+ $el
+ .removeClass(animation + ' animated')
+ .addClass(animation + ' animated')
+ .one 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', ->
+ $(this).removeClass(animation + ' animated')
+ if done?
+ done()
+ if options?.cssEnd?
+ $el.css(options.cssEnd)
+ return
+ return
+
+ gl.animate.animateEach = ($els, animation, time, options, done) ->
+ dfd = $.Deferred()
+ if not $els.length
+ dfd.resolve()
+ $els.each((i) ->
+ setTimeout(=>
+ $this = $(@)
+ gl.animate.animate($this, animation, options, =>
+ if i is $els.length - 1
+ dfd.resolve()
+ if done?
+ done()
+ )
+ ,time * i
+ )
+ return
+ )
+ return dfd.promise()
+ return
+) window \ No newline at end of file