Skip to content

Commit 8e3f6f8

Browse files
committed
chore: tidy up coffeescript and add generated files
1 parent 9516cdb commit 8e3f6f8

File tree

5 files changed

+53
-16
lines changed

5 files changed

+53
-16
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<a name="1.1.0"></a>
2+
## 1.1.0 (2014-05-21)
3+
4+
5+
#### Features
6+
7+
* add the ability to use animation loops ([b477632b](https://github.com/craigmdennis/animatecss/commit/b477632bc87f6d96d7ed2fd0ced0aec296c35952))
8+
9+
10+
#### Breaking Changes
11+
12+
* Delay can no longer be specified in the plugin shorthand ([89e7da1a](https://github.com/craigmdennis/animatecss/commit/89e7da1af66ba58c0078b426353b281b227c6844))
13+
14+
Before:
15+
16+
`$('#your-id').animateCSS('fadeIn', 2000);`
17+
18+
After:
19+
20+
`$('#your-id').animateCSS('fadeIn', {delay:2000});`

Gruntfile.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ module.exports = function (grunt) {
116116
}
117117
},
118118

119+
changelog: {
120+
options: {
121+
editor: 'atom -w'
122+
}
123+
},
124+
119125
connect: {
120126
options: {
121127
hostname: '0.0.0.0',

dist/jquery.animatecss.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! animateCSS - v1.0.6 - 2014-05-21
1+
/*! animateCSS - v1.1.0 - 2014-05-21
22
* https://github.com/craigmdennis/animatecss
33
* Copyright (c) 2014 Craig Dennis; Licensed MIT */
44

@@ -12,6 +12,7 @@
1212
animateCSS: function(effect, options) {
1313
var addClass, animate, callback, complete, init, removeClass, settings, transitionEnd, unhide;
1414
settings = {
15+
effect: effect,
1516
delay: 0,
1617
animationClass: "animated",
1718
infinite: false,
@@ -21,20 +22,20 @@
2122
transitionEnd = "webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend";
2223
settings = $.extend(settings, options);
2324
init = function(element) {
24-
animate(element);
25-
unhide(element);
26-
return complete(element);
25+
return animate(element);
2726
};
2827
animate = function(element) {
2928
if (settings.infinite === true) {
3029
settings.animationClass += " infinite";
3130
}
3231
return setTimeout(function() {
33-
return addClass(element);
32+
unhide(element);
33+
addClass(element);
34+
return complete(element);
3435
}, settings.delay);
3536
};
3637
addClass = function(element) {
37-
return element.addClass(effect + " " + settings.animationClass + " ");
38+
return element.addClass(settings.effect + " " + settings.animationClass + " ");
3839
};
3940
unhide = function(element) {
4041
if (element.css("visibility") === "hidden") {
@@ -45,14 +46,14 @@
4546
}
4647
};
4748
removeClass = function(element) {
48-
return element.removeClass(effect + " " + settings.animationClass);
49+
return element.removeClass(settings.effect + " " + settings.animationClass);
4950
};
5051
callback = function(element) {
5152
if (settings.infinite === false) {
5253
removeClass(element);
5354
}
5455
if (typeof settings.callback === "function") {
55-
return settings.callback.call(this);
56+
return settings.callback.call(element);
5657
}
5758
};
5859
complete = function(element) {

dist/jquery.animatecss.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/animatecss.coffee

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ $.fn.extend
88

99
# Change pluginName to your plugin's name.
1010
animateCSS: (effect, options) ->
11+
1112
# Default settings
1213
settings =
14+
effect: effect
1315
delay: 0
1416
animationClass: "animated",
1517
infinite: false
@@ -22,23 +24,25 @@ $.fn.extend
2224
# Merge default settings with options.
2325
settings = $.extend settings, options
2426

27+
# Call everything we need, in order
2528
init = ( element ) ->
2629
animate( element )
27-
unhide( element )
28-
complete( element )
2930

3031
# Add the animation effect with classes
3132
animate = ( element ) ->
3233
if settings.infinite == true
3334
settings.animationClass += " infinite"
3435

35-
# Run a timer regardless of delay as 0 will fire instantly anyway
36+
# Run a timer regardless of delay (as 0 will fire instantly anyway)
3637
setTimeout ->
38+
unhide( element )
3739
addClass( element )
40+
complete( element )
3841
, settings.delay
3942

43+
# Add the animation ad effect classes to kick everything off
4044
addClass = ( element ) ->
41-
element.addClass( effect + " " + settings.animationClass + " ")
45+
element.addClass( settings.effect + " " + settings.animationClass + " ")
4246

4347
# Check if the element has been hidden to start with
4448
unhide = ( element ) ->
@@ -47,19 +51,25 @@ $.fn.extend
4751

4852
# Remove the animation classes the were applied
4953
removeClass = ( element ) ->
50-
element.removeClass( effect + " " + settings.animationClass )
54+
element.removeClass( settings.effect + " " + settings.animationClass )
5155

5256
callback = ( element ) ->
57+
# Only remove the animation classes if `infinite` is false
5358
removeClass( element ) if settings.infinite == false
59+
60+
# Check if the callback is a function
5461
if typeof settings.callback == "function"
55-
settings.callback.call(this)
62+
# Execute the callback and return the origin element as `this`
63+
settings.callback.call( element )
5664

5765
# Event triggered when the animation has finished
5866
complete = ( element ) ->
5967
element.one( transitionEnd, ->
6068
callback( element )
6169
)
6270

71+
# Maintain chainability
6372
return @each () ->
6473

74+
# Pass in the element
6575
init( $(this) );

0 commit comments

Comments
 (0)