Skip to content

Commit 89e7da1

Browse files
committed
refactor: delay functions as expected
Reintroducted the delay functionality but within an options paramater rather than directly in the shorthand BREAKING CHANGE: Delay can no longer be specified in the plugin shorthand Before: .animateCSS('fadeIn', 2000) After: .animateCSS('fadeIn', {delay:2000})
1 parent 8052bc6 commit 89e7da1

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ module.exports = function (grunt) {
9292
tasks: ['jshint:gruntfile']
9393
},
9494
jade: {
95-
files: ['src/*.jade'],
95+
files: ['test/*.jade'],
9696
tasks: ['jade']
9797
},
9898
coffee: {

src/animatecss.coffee

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $.fn.extend
1111
# Default settings
1212
settings =
1313
effect: effect
14-
delay: false
14+
delay: 0
1515
animationClass: "animated",
1616
infinite: false
1717
callback: options
@@ -32,6 +32,13 @@ $.fn.extend
3232
animate = ( element ) ->
3333
if settings.infinite == true
3434
settings.animationClass += " infinite"
35+
36+
# Run a timer regardless of delay as 0 will fire instantly anyway
37+
setTimeout ->
38+
addClass( element )
39+
, settings.delay
40+
41+
addClass = ( element ) ->
3542
element.addClass( settings.effect + " " + settings.animationClass + " ")
3643

3744
# Check if the element has been hidden to start with
@@ -40,11 +47,11 @@ $.fn.extend
4047
element.show() if element.is(":hidden")
4148

4249
# Remove the animation classes the were applied
43-
clean = ( element ) ->
50+
removeClass = ( element ) ->
4451
element.removeClass( settings.effect + " " + settings.animationClass )
4552

4653
callback = ( element ) ->
47-
clean( element ) if settings.infinite == false
54+
removeClass( element ) if settings.infinite == false
4855
if typeof settings.callback == "function"
4956
settings.callback.call(this)
5057

0 commit comments

Comments
 (0)