turbolinks-animate 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9fdda2cd60cc0690b10d1ff749215e1e38189431229e385432453cfad05571a
4
- data.tar.gz: 7a267dc10022daa7b1c8fc395cfa94fefd5210a88ac289deb9b071de610aebdc
3
+ metadata.gz: f515e4834a613502b06c467550410dba996a782fa93ba48e658916f790eccdb6
4
+ data.tar.gz: 6e2558fc9e637e6fcc0dbf0ded48cd0b835a875f8bca743310fe181f72f7852b
5
5
  SHA512:
6
- metadata.gz: fa8415632c8a05539ff4b1d595cbddad1cb266f86e072291a893e634dbafb168bfec230a7ef9661498ddcdc84550064593a16aa4115354dc511584cfd8eb34ef
7
- data.tar.gz: d85eeebaa3b981e3ff6dbd53e9f8da4aaf0a528a152318eccb6e2f30cfcb20586106818b331f9f2f5f41b252d0138111139a1636b87fcdc20fea4a18bb077fca
6
+ metadata.gz: 160ca73d7dc05eb83ba2b0b35df27d11538cad35fc71a54149c0d3dd4f9f9299854d6d9e979241ae135e8a05d91bfea9f5996d41c5c3c5c10e2e6fd157059c9b
7
+ data.tar.gz: 70946fb6c2da93cbe6648c6951c518caac12b0f38d273b719d08c1dad078e800f715c3b9add4b8d9dc9150552cd77569f6c2992a91798ac103b1717de160a016
@@ -4,6 +4,11 @@
4
4
 
5
5
  * nothing yet
6
6
 
7
+ ### 1.3.0 - 2018-01-19
8
+
9
+ * enhancements
10
+ * updated [turbolinks-animate.js](https://github.com/jonhue/turbolinks-animate.js) to `2.0.0`
11
+
7
12
  ### 1.2.0 - 2018-01-06
8
13
 
9
14
  * enhancements
data/README.md CHANGED
@@ -17,6 +17,7 @@ This gem extends the [turbolinks-animate.js](https://github.com/jonhue/turbolink
17
17
  * [To Do](#to-do)
18
18
  * [Contributing](#contributing)
19
19
  * [Contributors](#contributors)
20
+ * [Semantic versioning](#semantic-versioning)
20
21
  * [License](#license)
21
22
 
22
23
  ---
@@ -51,14 +52,7 @@ The javascript and CSS files will be added to the asset pipeline and are availab
51
52
  //= require turbolinks-animate
52
53
 
53
54
  $(document).on( 'turbolinks:load', function() {
54
- $('body.turbolinks-animate').turbolinksAnimate();
55
- turbolinksAnimateAppear();
56
- });
57
- $(document).on( 'turbolinks:request-start', function() {
58
- turbolinksAnimateDisappear();
59
- });
60
- $(window).on( 'popstate beforeunload', function(event) {
61
- turbolinksAnimateDisappear();
55
+ TurbolinksAnimate.init();
62
56
  });
63
57
  ```
64
58
 
@@ -115,6 +109,10 @@ Give the people some :heart: who are working on this project. See them all at:
115
109
 
116
110
  https://github.com/jonhue/turbolinks-animate/graphs/contributors
117
111
 
112
+ ### Semantic Versioning
113
+
114
+ turbolinks-animate follows Semantic Versioning 2.0 as defined at http://semver.org.
115
+
118
116
  ## License
119
117
 
120
118
  MIT License
@@ -1,3 +1,3 @@
1
1
  module TurbolinksAnimate
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  /**!
2
2
  * @fileOverview turbolinks-animate.js - Animations extending Turbolinks
3
- * @version 1.3.8
3
+ * @version 2.0.0
4
4
  * @license
5
5
  * MIT License
6
6
  *
@@ -24,177 +24,268 @@
24
24
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
25
  * SOFTWARE.
26
26
  */
27
- $.fn.extend({
28
- turbolinksAnimate: function(options) {
27
+ var TurbolinksAnimate = new function() {
28
+
29
+ this.options = {};
30
+ this.inline = false;
31
+ this.element = null;
32
+ this.elements = null;
33
+ this.disappearing = false;
34
+ this.initialized = false;
35
+ this.animations = [
36
+ { name: 'fadeIn', disappear: 'fadeOut', reverse: null },
37
+ { name: 'fadeOut', disappear: true, reverse: null },
38
+ { name: 'fadeInUp', disappear: 'fadeOutUp', reverse: 'fadeInDown' },
39
+ { name: 'fadeOutUp', disappear: true, reverse: 'fadeOutDown' },
40
+ { name: 'fadeInDown', disappear: 'fadeOutDown', reverse: 'fadeInUp' },
41
+ { name: 'fadeOutDown', disappear: true, reverse: 'fadeOutUp' },
42
+ { name: 'fadeInLeft', disappear: 'fadeOutLeft', reverse: 'fadeInRight' },
43
+ { name: 'fadeOutLeft', disappear: true, reverse: 'fadeOutRight' },
44
+ { name: 'fadeInRight', disappear: 'fadeOutRight', reverse: 'fadeInLeft' },
45
+ { name: 'fadeOutRight', disappear: true, reverse: 'fadeOutLeft' },
46
+ { name: 'fadeInUpBig', disappear: 'fadeOutUpBig', reverse: 'fadeInDownBig' },
47
+ { name: 'fadeOutUpBig', disappear: true, reverse: 'fadeOutDownBig' },
48
+ { name: 'fadeInDownBig', disappear: 'fadeOutDownBig', reverse: 'fadeInUpBig' },
49
+ { name: 'fadeOutDownBig', disappear: true, reverse: 'fadeOutUpBig' },
50
+ { name: 'fadeInLeftBig', disappear: 'fadeOutLeftBig', reverse: 'fadeInRightBig' },
51
+ { name: 'fadeOutLeftBig', disappear: true, reverse: 'fadeOutRightBig' },
52
+ { name: 'fadeInRightBig', disappear: 'fadeOutRightBig', reverse: 'fadeInLeftBig' },
53
+ { name: 'fadeOutRightBig', disappear: true, reverse: 'fadeOutLeftBig' },
54
+ { name: 'bounceIn', disappear: 'bounceOut', reverse: null },
55
+ { name: 'bounceOut', disappear: true, reverse: null },
56
+ { name: 'bounceInUp', disappear: 'bounceOutUp', reverse: 'bounceInDown' },
57
+ { name: 'bounceOutUp', disappear: true, reverse: 'bounceOutDown' },
58
+ { name: 'bounceInDown', disappear: 'bounceOutDown', reverse: 'bounceInUp' },
59
+ { name: 'bounceOutDown', disappear: true, reverse: 'bounceOutUp' },
60
+ { name: 'bounceInLeft', disappear: 'bounceOutLeft', reverse: 'bounceInRight' },
61
+ { name: 'bounceOutLeft', disappear: true, reverse: 'bounceOutRight' },
62
+ { name: 'bounceInRight', disappear: 'bounceOutRight', reverse: 'bounceInLeft' },
63
+ { name: 'bounceOutRight', disappear: true, reverse: 'bounceOutLeft' },
64
+ { name: 'flipInX', disappear: 'flipOutX', reverse: 'flipInY' },
65
+ { name: 'flipOutX', disappear: true, reverse: 'flipOutY' },
66
+ { name: 'flipInY', disappear: 'flipOutY', reverse: 'flipInX' },
67
+ { name: 'flipOutY', disappear: true, reverse: 'flipOutX' },
68
+ { name: 'lightSpeedIn', disappear: 'lightSpeedOut', reverse: null },
69
+ { name: 'lightSpeedOut', disappear: true, reverse: null },
70
+ { name: 'rotateIn', disappear: 'rotateOut', reverse: null },
71
+ { name: 'rotateOut', disappear: true, reverse: null },
72
+ { name: 'rotateInDownLeft', disappear: 'rotateOutDownLeft', reverse: 'rotateInUpRight' },
73
+ { name: 'rotateOutDownLeft', disappear: true, reverse: 'rotateOutUpRight' },
74
+ { name: 'rotateInDownRight', disappear: 'rotateOutDownRight', reverse: 'rotateInUpLeft' },
75
+ { name: 'rotateOutDownRight', disappear: true, reverse: 'rotateOutUpLeft' },
76
+ { name: 'rotateInUpLeft', disappear: 'rotateOutUpLeft', reverse: 'rotateInDownRight' },
77
+ { name: 'rotateOutUpLeft', disappear: true, reverse: 'rotateOutDownRight' },
78
+ { name: 'rotateInUpRight', disappear: 'rotateOutUpRight', reverse: 'rotateInDownLeft' },
79
+ { name: 'rotateOutUpRight', disappear: true, reverse: 'rotateOutDownLeft' },
80
+ { name: 'rollIn', disappear: 'rollOut', reverse: null },
81
+ { name: 'rollOut', disappear: true, reverse: null },
82
+ { name: 'zoomIn', disappear: 'zoomOut', reverse: null },
83
+ { name: 'zoomOut', disappear: true, reverse: null },
84
+ { name: 'zoomInUp', disappear: 'zoomOutUp', reverse: 'zoomInDown' },
85
+ { name: 'zoomOutUp', disappear: true, reverse: 'zoomOutDown' },
86
+ { name: 'zoomInDown', disappear: 'zoomOutDown', reverse: 'zoomInUp' },
87
+ { name: 'zoomOutDown', disappear: true, reverse: 'zoomOutUp' },
88
+ { name: 'zoomInLeft', disappear: 'zoomOutLeft', reverse: 'zoomInRight' },
89
+ { name: 'zoomOutLeft', disappear: true, reverse: 'zoomOutRight' },
90
+ { name: 'zoomInRight', disappear: 'zoomOutRight', reverse: 'zoomInLeft' },
91
+ { name: 'zoomOutRight', disappear: true, reverse: 'zoomOutLeft' },
92
+ { name: 'slideInUp', disappear: 'slideOutUp', reverse: 'slideInDown' },
93
+ { name: 'slideOutUp', disappear: true, reverse: 'slideOutDown' },
94
+ { name: 'slideInDown', disappear: 'slideOutDown', reverse: 'slideInUp' },
95
+ { name: 'slideOutDown', disappear: true, reverse: 'slideOutUp' },
96
+ { name: 'slideInLeft', disappear: 'slideOutLeft', reverse: 'slideInRight' },
97
+ { name: 'slideOutLeft', disappear: true, reverse: 'slideOutRight' },
98
+ { name: 'slideInRight', disappear: 'slideOutRight', reverse: 'slideInLeft' },
99
+ { name: 'slideOutRight', disappear: true, reverse: 'slideOutLeft' }
100
+ ];
101
+ var array = [];
102
+ $.each( this.animations, function( k, animation ) {
103
+ array.push(animation.name);
104
+ });
105
+ this.animateClasses = array;
106
+
107
+ this.init = function(options) {
108
+
29
109
  var defaults = {
110
+ element: $('body'),
30
111
  animation: 'fadein',
31
112
  duration: '0.3s',
32
113
  delay: false,
33
- reversedDisappearing: true,
34
- mobileMedia: '500',
35
- tabletMedia: '1024'
114
+ reversedDisappearing: false,
115
+ breakpoints: [
116
+ { name: 'mobile', width: 500 },
117
+ { name: 'tablet', width: 1024 },
118
+ { name: 'desktop', width: 1440 }
119
+ ],
120
+ customListeners: false
36
121
  };
37
-
38
122
  options = $.extend( defaults, options );
39
123
 
40
- turbolinksAnimateInit( $(this), options );
41
- }
42
- });
43
-
44
-
45
- var turbolinksAnimateData = {}, turbolinksAnimateInline = false, turbolinksAnimateElement, turbolinksAnimateElements;
46
-
47
- function turbolinksAnimateInit( el, options ) {
48
- var turbolinksAnimatePreviousType = turbolinksAnimateData['type'],
49
- turbolinksAnimateAppear = turbolinksAnimateData['appear'];
50
- turbolinksAnimateData = {};
51
- turbolinksAnimateElement = el;
52
- turbolinksAnimateData['animation'] = options.animation;
53
- turbolinksAnimateData['duration'] = options.duration;
54
- turbolinksAnimateData['delay'] = options.delay;
55
- turbolinksAnimateData['mobileMedia'] = options.mobileMedia;
56
- turbolinksAnimateData['tabletMedia'] = options.tabletMedia;
57
- turbolinksAnimateData['appear'] = turbolinksAnimateAppear;
58
- turbolinksAnimateData['previousType'] = turbolinksAnimatePreviousType;
59
- $('a, button').click( function() {
60
- if ( $(this).data('turbolinks-animate-animation') !== undefined ) { turbolinksAnimateInline = true };
61
- turbolinksAnimateData['animation'] = $(this).data('turbolinks-animate-animation') || options.animation;
62
- turbolinksAnimateData['appear'] = $(this).data('turbolinks-animate-appear');
63
- turbolinksAnimateData['duration'] = $(this).data('turbolinks-animate-duration') || options.duration;
64
- turbolinksAnimateData['delay'] = $(this).data('turbolinks-animate-delay') || options.delay;
65
- turbolinksAnimateData['type'] = $(this).data('turbolinks-animate-type');
66
- });
67
- };
68
-
69
-
124
+ TurbolinksAnimate.element = options.element;
125
+ TurbolinksAnimate.setOptions(options);
70
126
 
71
- function turbolinksAnimateAppear() {
72
- turbolinksAnimateToggle(false);
73
- delete turbolinksAnimateData['appear'];
74
- };
127
+ if ( TurbolinksAnimate.initialized == false && options.customListeners == false ) {
128
+ $(document).on( 'turbolinks:request-start', function() {
129
+ TurbolinksAnimate.disappear();
130
+ });
131
+ $(window).on( 'popstate beforeunload', function() {
132
+ TurbolinksAnimate.disappear();
133
+ });
134
+ };
75
135
 
76
- function turbolinksAnimateDisappear() {
77
- turbolinksAnimateToggle(true);
78
- };
136
+ $('a, button').click(function() {
137
+ if ( typeof $(this).data('turbolinks-animate-animation') !== 'undefined' ) {
138
+ TurbolinksAnimate.inline = true;
139
+ };
140
+ TurbolinksAnimate.options.animation = $(this).data('turbolinks-animate-animation') || options.animation;
141
+ TurbolinksAnimate.options.appear = $(this).data('turbolinks-animate-appear');
142
+ TurbolinksAnimate.options.duration = $(this).data('turbolinks-animate-duration') || options.duration;
143
+ TurbolinksAnimate.options.delay = $(this).data('turbolinks-animate-delay') || options.delay;
144
+ TurbolinksAnimate.options.type = $(this).data('turbolinks-animate-type');
145
+ });
79
146
 
80
- function turbolinksAnimateToggle(disappears) {
81
- if ( turbolinksAnimateData['animation'] != 'false' ) {
82
- turbolinksAnimateReset();
83
- turbolinksAnimateOptions();
147
+ TurbolinksAnimate.initialized = true;
148
+ if ( options.customListeners == false ) {
149
+ TurbolinksAnimate.appear();
150
+ };
84
151
 
85
- Turbolinks.clearCache() // fix cache issues
86
- turbolinksAnimateAnimateElements(disappears);
87
152
  };
88
- };
89
153
 
154
+ this.setOptions = function(options) {
90
155
 
156
+ var previousType = TurbolinksAnimate.options.type,
157
+ appear = TurbolinksAnimate.options.appear;
158
+
159
+ TurbolinksAnimate.options = {
160
+ animation: options.animation,
161
+ duration: options.duration,
162
+ delay: options.delay,
163
+ reversedDisappearing: options.reversedDisappearing,
164
+ breakpoints: options.breakpoints,
165
+ previousType: previousType,
166
+ appear: appear
167
+ };
91
168
 
92
- function turbolinksAnimateGetAnimation(disappears) {
93
- var animation;
94
- if (!disappears) { animation = turbolinksAnimateData['appear'] };
95
- if (turbolinksAnimateInline) {
96
- animation = turbolinksAnimateData['animation']
97
- } else if ( typeof turbolinksAnimateElement.data('turbolinks-animate-animation') !== 'undefined' ) {
98
- animation = turbolinksAnimateElement.data('turbolinks-animate-animation')
99
- } else {
100
- animation = turbolinksAnimateData['animation'];
101
169
  };
102
- return animation;
103
- };
104
170
 
105
- function turbolinksAnimateOptions() {
106
- turbolinksAnimateElement.css('animationDuration', turbolinksAnimateData['duration']);
107
- if (turbolinksAnimateData['delay'] != false) {
108
- turbolinksAnimateElement.css('animationDelay', turbolinksAnimateData['delay']);
171
+ this.appear = function() {
172
+ TurbolinksAnimate.disappearing = false;
173
+ TurbolinksAnimate.toggle();
109
174
  };
110
- if ( typeof turbolinksAnimateElements !== 'undefined' ) {
111
- $(turbolinksAnimateElements).each(function() {
112
- $(this).css('animationDuration', turbolinksAnimateData['duration']);
113
- if (turbolinksAnimateData['delay'] != false) {
114
- $(this).css('animationDelay', turbolinksAnimateData['delay']);
175
+ this.disappear = function() {
176
+ TurbolinksAnimate.disappearing = true;
177
+ TurbolinksAnimate.toggle();
178
+ };
179
+ this.toggle = function() {
180
+ if ( TurbolinksAnimate.options.animation != 'false' ) {
181
+ TurbolinksAnimate.resetClasses();
182
+ TurbolinksAnimate.getElements();
183
+ TurbolinksAnimate.useOptions();
184
+ Turbolinks.clearCache(); // fix cache issues
185
+ TurbolinksAnimate.animate();
186
+ TurbolinksAnimate.reset();
187
+ };
188
+ };
189
+
190
+ this.getElements = function() {
191
+ TurbolinksAnimate.elements = [];
192
+
193
+ function getChildren(parent) {
194
+ var type = TurbolinksAnimate.options.type || TurbolinksAnimate.options.previousType || 'true';
195
+ if ( parent.data('turbolinks-animate-persist') == type ) {
196
+ return;
197
+ } else if ( parent.data('turbolinks-animate-persist-itself') == type || parent.find('[data-turbolinks-animate-persist]').length > 0 || parent.find('[data-turbolinks-animate-persist-itself]').length > 0 ) {
198
+ parent.children().each(function() {
199
+ getChildren($(this));
200
+ });
201
+ } else {
202
+ TurbolinksAnimate.elements.push(parent);
115
203
  };
116
- });
204
+ };
205
+
206
+ getChildren(TurbolinksAnimate.element);
207
+ };
208
+ this.useOptions = function() {
209
+ if ( TurbolinksAnimate.elements != null ) {
210
+ $(TurbolinksAnimate.elements).each(function() {
211
+ $(this).css( 'animationDuration', TurbolinksAnimate.options.duration );
212
+ if ( TurbolinksAnimate.options.delay != false ) {
213
+ $(this).css( 'animationDelay', TurbolinksAnimate.options.delay );
214
+ };
215
+ });
216
+ };
117
217
  };
118
- };
119
218
 
120
- function turbolinksAnimateReset() {
121
- var classes = 'fadeIn fadeInUp fadeInDown fadeInLeft fadeInRightfadeOut fadeOutUp fadeOutDown fadeOutLeft fadeOutRight';
122
- if ( typeof turbolinksAnimateElements !== 'undefined' ) {
123
- $(turbolinksAnimateElements).each(function() {
124
- $(this).removeClass(classes);
219
+ this.reset = function() {
220
+ delete TurbolinksAnimate.options.appear;
221
+ delete TurbolinksAnimate.options.previousType;
222
+ TurbolinksAnimate.inline = false;
223
+ };
224
+ this.resetClasses = function() {
225
+ $(TurbolinksAnimate.elements).each(function() {
226
+ $(this).removeClass(TurbolinksAnimate.animateClasses.join(' '));
125
227
  });
126
228
  };
127
- turbolinksAnimateElement.removeClass(classes);
128
- };
129
229
 
130
-
131
-
132
- function turbolinksAnimateAnimateElements(disappears) {
133
- if ( turbolinksAnimateElement.find('[data-turbolinks-animate-persist]').length > 0 || turbolinksAnimateElement.find('[data-turbolinks-animate-persist-itself]').length > 0 ) {
134
- turbolinksAnimateElements = turbolinksAnimateGetElements();
135
- $(turbolinksAnimateElements).each(function() {
230
+ this.animate = function() {
231
+ $(TurbolinksAnimate.elements).each(function() {
136
232
  $(this).one( 'webkitAnimationEnd mozAnimationEnd oAnimationEnd oanimationend animationend', function() {
137
233
  setTimeout(function() {
138
- turbolinksAnimateReset();
234
+ if ( TurbolinksAnimate.disappearing == false ) {
235
+ TurbolinksAnimate.resetClasses();
236
+ };
139
237
  }, 250);
140
238
  });
141
- $(this).addClass(turbolinksAnimateGetClassListFor( turbolinksAnimateGetAnimation(disappears), disappears ));
239
+ $(this).addClass(TurbolinksAnimate.getClassListFor(TurbolinksAnimate.getAnimation()));
142
240
  });
143
241
  };
144
- turbolinksAnimateElement.one( 'webkitAnimationEnd mozAnimationEnd oAnimationEnd oanimationend animationend', function() {
145
- setTimeout(function() {
146
- turbolinksAnimateReset();
147
- }, 250);
148
- });
149
- turbolinksAnimateElement.addClass(turbolinksAnimateGetClassListFor( turbolinksAnimateGetAnimation(disappears), disappears ));
150
-
151
- delete turbolinksAnimateData['previousType'];
152
- turbolinksAnimateInline = false;
153
- };
154
-
155
- function turbolinksAnimateGetElements() {
156
- var turbolinksAnimateElements = [];
157
-
158
- getChildren(turbolinksAnimateElement);
242
+ this.getAnimation = function() {
243
+ var animation;
159
244
 
160
- function getChildren(parent) {
161
- var turbolinksAnimateType = turbolinksAnimateData['type'] || turbolinksAnimateData['previousType'] || 'true';
162
- if (parent.attr('data-turbolinks-animate-persist') == turbolinksAnimateType) {
163
- return;
164
- } else if ( parent.attr('data-turbolinks-animate-persist-itself') == turbolinksAnimateType || parent.find('[data-turbolinks-animate-persist]').length > 0 || parent.find('[data-turbolinks-animate-persist-itself]').length > 0 ) {
165
- parent.children().each(function() {
166
- getChildren($(this));
167
- });
245
+ if (!TurbolinksAnimate.disappearing) { animation = TurbolinksAnimate.options.appear };
246
+ if (TurbolinksAnimate.inline) {
247
+ animation = TurbolinksAnimate.options.animation;
248
+ } else if ( typeof TurbolinksAnimate.element.data('turbolinks-animate-animation') !== 'undefined' ) {
249
+ animation = TurbolinksAnimate.element.data('turbolinks-animate-animation');
168
250
  } else {
169
- turbolinksAnimateElements.push(parent);
251
+ animation = TurbolinksAnimate.options.animation;
170
252
  };
171
- };
172
253
 
173
- return turbolinksAnimateElements
174
- };
254
+ return animation;
255
+ };
256
+ this.getClassListFor = function(animations) {
257
+ var classList = 'animated',
258
+ browserWidth = $(window).width(),
259
+ animation = null;
175
260
 
261
+ var breakpoints = TurbolinksAnimate.options.breakpoints.sort(function( a, b ) {
262
+ return b.width - a.width;
263
+ });
264
+ $.each( breakpoints, function( k, breakpoint ) {
265
+ if ( animation == null && browserWidth <= breakpoint.width ) {
266
+ animation = animations[breakpoint.name.toString()];
267
+ };
268
+ });
269
+ if ( animation == null ) {
270
+ animation = animations;
271
+ };
176
272
 
273
+ classList += ' ';
274
+ animation = $.grep( TurbolinksAnimate.animations, function(object) { return object.name.toLowerCase() == animation.toLowerCase() })[0];
275
+ if ( TurbolinksAnimate.disappearing ) {
276
+ if ( animation.disappear != true ) {
277
+ animation = $.grep( TurbolinksAnimate.animations, function(object) { return object.name.toLowerCase() == animation.disappear.toLowerCase() })[0];
278
+ };
279
+ if ( TurbolinksAnimate.options.reversedDisappearing && animation.reverse != null ) {
280
+ classList += animation.reverse;
281
+ } else {
282
+ classList += animation.name;
283
+ };
284
+ } else {
285
+ classList += animation.name;
286
+ };
177
287
 
178
- function turbolinksAnimateGetClassListFor( animations, disappears ) {
179
- var classList = 'animated',
180
- browserWidth = $(window).width();
181
- if ( browserWidth <= turbolinksAnimateData['mobileMedia'] ) {
182
- var animation = animations['mobile'] || animations['tablet'] || animations['desktop'] || animations;
183
- } else if ( browserWidth <= turbolinksAnimateData['tabletMedia'] ) {
184
- var animation = animations['tablet'] || animations['desktop'] || animations;
185
- } else {
186
- var animation = animations['desktop'] || animations;
288
+ return classList;
187
289
  };
188
- animation.toLowerCase();
189
- if ( animation == 'fadein' ) { classList += ( disappears ? ' fadeOut' : ' fadeIn' ) }
190
- else if ( animation == 'fadeinup' ) { classList += ( disappears ? ( turbolinksAnimateData['reversedDisappearing'] ? ' fadeOutDown' : ' fadeOutUp' ) : ' fadeInUp' ) }
191
- else if ( animation == 'fadeindown' ) { classList += ( disappears ? ( turbolinksAnimateData['reversedDisappearing'] ? ' fadeOutUp' : ' fadeOutDown' ) : ' fadeInDown' ) }
192
- else if ( animation == 'fadeinleft' ) { classList += ( disappears ? ' fadeOutLeft' : ' fadeInLeft' ) }
193
- else if ( animation == 'fadeinright' ) { classList += ( disappears ? ' fadeOutRight' : ' fadeInRight' ) }
194
- else if ( animation == 'fadeout' ) { classList += ' fadeOut' }
195
- else if ( animation == 'fadeoutup' ) { classList += ( turbolinksAnimateData['reversedDisappearing'] ? ' fadeOutDown' : ' fadeOutUp' ) }
196
- else if ( animation == 'fadeoutdown' ) { classList += ( turbolinksAnimateData['reversedDisappearing'] ? ' fadeOutUp' : ' fadeOutDown' ) }
197
- else if ( animation == 'fadeoutleft' ) { classList += ' fadeOutLeft' }
198
- else if ( animation == 'fadeoutright' ) { classList += ' fadeOutRight' };
199
- return classList;
290
+
200
291
  };
@@ -1,6 +1,6 @@
1
1
  /**!
2
2
  * @fileOverview turbolinks-animate.js - Animations extending Turbolinks
3
- * @version 1.3.8
3
+ * @version 2.0.0
4
4
  * @license
5
5
  * MIT License
6
6
  *
@@ -24,4 +24,4 @@
24
24
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
25
  * SOFTWARE.
26
26
  */
27
- $.fn.extend({turbolinksAnimate:function(a){var b={animation:"fadein",duration:"0.3s",delay:false,reversedDisappearing:true,mobileMedia:"500",tabletMedia:"1024"};a=$.extend(b,a);turbolinksAnimateInit($(this),a)}});var turbolinksAnimateData={},turbolinksAnimateInline=false,turbolinksAnimateElement,turbolinksAnimateElements;function turbolinksAnimateInit(c,b){var d=turbolinksAnimateData.type,a=turbolinksAnimateData.appear;turbolinksAnimateData={};turbolinksAnimateElement=c;turbolinksAnimateData.animation=b.animation;turbolinksAnimateData.duration=b.duration;turbolinksAnimateData.delay=b.delay;turbolinksAnimateData.mobileMedia=b.mobileMedia;turbolinksAnimateData.tabletMedia=b.tabletMedia;turbolinksAnimateData.appear=a;turbolinksAnimateData.previousType=d;$("a, button").click(function(){if($(this).data("turbolinks-animate-animation")!==undefined){turbolinksAnimateInline=true}turbolinksAnimateData.animation=$(this).data("turbolinks-animate-animation")||b.animation;turbolinksAnimateData.appear=$(this).data("turbolinks-animate-appear");turbolinksAnimateData.duration=$(this).data("turbolinks-animate-duration")||b.duration;turbolinksAnimateData.delay=$(this).data("turbolinks-animate-delay")||b.delay;turbolinksAnimateData.type=$(this).data("turbolinks-animate-type")})}function turbolinksAnimateAppear(){turbolinksAnimateToggle(false);delete turbolinksAnimateData.appear}function turbolinksAnimateDisappear(){turbolinksAnimateToggle(true)}function turbolinksAnimateToggle(a){if(turbolinksAnimateData.animation!="false"){turbolinksAnimateReset();turbolinksAnimateOptions();Turbolinks.clearCache();turbolinksAnimateAnimateElements(a)}}function turbolinksAnimateGetAnimation(a){var b;if(!a){b=turbolinksAnimateData.appear}if(turbolinksAnimateInline){b=turbolinksAnimateData.animation}else{if(typeof turbolinksAnimateElement.data("turbolinks-animate-animation")!=="undefined"){b=turbolinksAnimateElement.data("turbolinks-animate-animation")}else{b=turbolinksAnimateData.animation}}return b}function turbolinksAnimateOptions(){turbolinksAnimateElement.css("animationDuration",turbolinksAnimateData.duration);if(turbolinksAnimateData.delay!=false){turbolinksAnimateElement.css("animationDelay",turbolinksAnimateData.delay)}if(typeof turbolinksAnimateElements!=="undefined"){$(turbolinksAnimateElements).each(function(){$(this).css("animationDuration",turbolinksAnimateData.duration);if(turbolinksAnimateData.delay!=false){$(this).css("animationDelay",turbolinksAnimateData.delay)}})}}function turbolinksAnimateReset(){if(typeof turbolinksAnimateElements!=="undefined"){$(turbolinksAnimateElements).each(function(){$(this).removeClass("fadeIn fadeInUp fadeInDown fadeInLeft fadeInRightfadeOut fadeOutUp fadeOutDown fadeOutLeft fadeOutRight")})}turbolinksAnimateElement.removeClass("fadeIn fadeInUp fadeInDown fadeInLeft fadeInRightfadeOut fadeOutUp fadeOutDown fadeOutLeft fadeOutRight")}function turbolinksAnimateAnimateElements(a){if(turbolinksAnimateElement.find("[data-turbolinks-animate-persist]").length>0||turbolinksAnimateElement.find("[data-turbolinks-animate-persist-itself]").length>0){turbolinksAnimateElements=turbolinksAnimateGetElements();$(turbolinksAnimateElements).each(function(){$(this).one("webkitAnimationEnd mozAnimationEnd oAnimationEnd oanimationend animationend",function(){setTimeout(function(){turbolinksAnimateReset()},250)});$(this).addClass(turbolinksAnimateGetClassListFor(turbolinksAnimateGetAnimation(a),a))})}turbolinksAnimateElement.one("webkitAnimationEnd mozAnimationEnd oAnimationEnd oanimationend animationend",function(){setTimeout(function(){turbolinksAnimateReset()},250)});turbolinksAnimateElement.addClass(turbolinksAnimateGetClassListFor(turbolinksAnimateGetAnimation(a),a));delete turbolinksAnimateData.previousType;turbolinksAnimateInline=false}function turbolinksAnimateGetElements(){var a=[];b(turbolinksAnimateElement);function b(c){var d=turbolinksAnimateData.type||turbolinksAnimateData.previousType||"true";if(c.attr("data-turbolinks-animate-persist")==d){return}else{if(c.attr("data-turbolinks-animate-persist-itself")==d||c.find("[data-turbolinks-animate-persist]").length>0||c.find("[data-turbolinks-animate-persist-itself]").length>0){c.children().each(function(){b($(this))})}else{a.push(c)}}}return a}function turbolinksAnimateGetClassListFor(e,a){var d="animated",c=$(window).width();if(c<=turbolinksAnimateData.mobileMedia){var b=e.mobile||e.tablet||e.desktop||e}else{if(c<=turbolinksAnimateData.tabletMedia){var b=e.tablet||e.desktop||e}else{var b=e.desktop||e}}b.toLowerCase();if(b=="fadein"){d+=(a?" fadeOut":" fadeIn")}else{if(b=="fadeinup"){d+=(a?(turbolinksAnimateData.reversedDisappearing?" fadeOutDown":" fadeOutUp"):" fadeInUp")}else{if(b=="fadeindown"){d+=(a?(turbolinksAnimateData.reversedDisappearing?" fadeOutUp":" fadeOutDown"):" fadeInDown")}else{if(b=="fadeinleft"){d+=(a?" fadeOutLeft":" fadeInLeft")}else{if(b=="fadeinright"){d+=(a?" fadeOutRight":" fadeInRight")}else{if(b=="fadeout"){d+=" fadeOut"}else{if(b=="fadeoutup"){d+=(turbolinksAnimateData.reversedDisappearing?" fadeOutDown":" fadeOutUp")}else{if(b=="fadeoutdown"){d+=(turbolinksAnimateData.reversedDisappearing?" fadeOutUp":" fadeOutDown")}else{if(b=="fadeoutleft"){d+=" fadeOutLeft"}else{if(b=="fadeoutright"){d+=" fadeOutRight"}}}}}}}}}}return d};
27
+ var TurbolinksAnimate=TurbolinksAnimate||new function(){this.options={};this.inline=false;this.element=null;this.elements=null;this.disappearing=false;this.initialized=false;this.animations=[{name:"fadeIn",disappear:"fadeOut",reverse:null},{name:"fadeOut",disappear:true,reverse:null},{name:"fadeInUp",disappear:"fadeOutUp",reverse:"fadeInDown"},{name:"fadeOutUp",disappear:true,reverse:"fadeOutDown"},{name:"fadeInDown",disappear:"fadeOutDown",reverse:"fadeInUp"},{name:"fadeOutDown",disappear:true,reverse:"fadeOutUp"},{name:"fadeInLeft",disappear:"fadeOutLeft",reverse:"fadeInRight"},{name:"fadeOutLeft",disappear:true,reverse:"fadeOutRight"},{name:"fadeInRight",disappear:"fadeOutRight",reverse:"fadeInLeft"},{name:"fadeOutRight",disappear:true,reverse:"fadeOutLeft"},{name:"fadeInUpBig",disappear:"fadeOutUpBig",reverse:"fadeInDownBig"},{name:"fadeOutUpBig",disappear:true,reverse:"fadeOutDownBig"},{name:"fadeInDownBig",disappear:"fadeOutDownBig",reverse:"fadeInUpBig"},{name:"fadeOutDownBig",disappear:true,reverse:"fadeOutUpBig"},{name:"fadeInLeftBig",disappear:"fadeOutLeftBig",reverse:"fadeInRightBig"},{name:"fadeOutLeftBig",disappear:true,reverse:"fadeOutRightBig"},{name:"fadeInRightBig",disappear:"fadeOutRightBig",reverse:"fadeInLeftBig"},{name:"fadeOutRightBig",disappear:true,reverse:"fadeOutLeftBig"},{name:"bounceIn",disappear:"bounceOut",reverse:null},{name:"bounceOut",disappear:true,reverse:null},{name:"bounceInUp",disappear:"bounceOutUp",reverse:"bounceInDown"},{name:"bounceOutUp",disappear:true,reverse:"bounceOutDown"},{name:"bounceInDown",disappear:"bounceOutDown",reverse:"bounceInUp"},{name:"bounceOutDown",disappear:true,reverse:"bounceOutUp"},{name:"bounceInLeft",disappear:"bounceOutLeft",reverse:"bounceInRight"},{name:"bounceOutLeft",disappear:true,reverse:"bounceOutRight"},{name:"bounceInRight",disappear:"bounceOutRight",reverse:"bounceInLeft"},{name:"bounceOutRight",disappear:true,reverse:"bounceOutLeft"},{name:"flipInX",disappear:"flipOutX",reverse:"flipInY"},{name:"flipOutX",disappear:true,reverse:"flipOutY"},{name:"flipInY",disappear:"flipOutY",reverse:"flipInX"},{name:"flipOutY",disappear:true,reverse:"flipOutX"},{name:"lightSpeedIn",disappear:"lightSpeedOut",reverse:null},{name:"lightSpeedOut",disappear:true,reverse:null},{name:"rotateIn",disappear:"rotateOut",reverse:null},{name:"rotateOut",disappear:true,reverse:null},{name:"rotateInDownLeft",disappear:"rotateOutDownLeft",reverse:"rotateInUpRight"},{name:"rotateOutDownLeft",disappear:true,reverse:"rotateOutUpRight"},{name:"rotateInDownRight",disappear:"rotateOutDownRight",reverse:"rotateInUpLeft"},{name:"rotateOutDownRight",disappear:true,reverse:"rotateOutUpLeft"},{name:"rotateInUpLeft",disappear:"rotateOutUpLeft",reverse:"rotateInDownRight"},{name:"rotateOutUpLeft",disappear:true,reverse:"rotateOutDownRight"},{name:"rotateInUpRight",disappear:"rotateOutUpRight",reverse:"rotateInDownLeft"},{name:"rotateOutUpRight",disappear:true,reverse:"rotateOutDownLeft"},{name:"rollIn",disappear:"rollOut",reverse:null},{name:"rollOut",disappear:true,reverse:null},{name:"zoomIn",disappear:"zoomOut",reverse:null},{name:"zoomOut",disappear:true,reverse:null},{name:"zoomInUp",disappear:"zoomOutUp",reverse:"zoomInDown"},{name:"zoomOutUp",disappear:true,reverse:"zoomOutDown"},{name:"zoomInDown",disappear:"zoomOutDown",reverse:"zoomInUp"},{name:"zoomOutDown",disappear:true,reverse:"zoomOutUp"},{name:"zoomInLeft",disappear:"zoomOutLeft",reverse:"zoomInRight"},{name:"zoomOutLeft",disappear:true,reverse:"zoomOutRight"},{name:"zoomInRight",disappear:"zoomOutRight",reverse:"zoomInLeft"},{name:"zoomOutRight",disappear:true,reverse:"zoomOutLeft"},{name:"slideInUp",disappear:"slideOutUp",reverse:"slideInDown"},{name:"slideOutUp",disappear:true,reverse:"slideOutDown"},{name:"slideInDown",disappear:"slideOutDown",reverse:"slideInUp"},{name:"slideOutDown",disappear:true,reverse:"slideOutUp"},{name:"slideInLeft",disappear:"slideOutLeft",reverse:"slideInRight"},{name:"slideOutLeft",disappear:true,reverse:"slideOutRight"},{name:"slideInRight",disappear:"slideOutRight",reverse:"slideInLeft"},{name:"slideOutRight",disappear:true,reverse:"slideOutLeft"}];var a=[];$.each(this.animations,function(b,c){a.push(c.name)});this.animateClasses=a;this.init=function(b){var c={element:$("body"),animation:"fadein",duration:"0.3s",delay:false,reversedDisappearing:false,breakpoints:[{name:"mobile",width:500},{name:"tablet",width:1024},{name:"desktop",width:1440}],customListeners:false};b=$.extend(c,b);TurbolinksAnimate.element=b.element;TurbolinksAnimate.setOptions(b);if(TurbolinksAnimate.initialized==false&&b.customListeners==false){$(document).on("turbolinks:request-start",function(){TurbolinksAnimate.disappear()});$(window).on("popstate beforeunload",function(){TurbolinksAnimate.disappear()})}$("a, button").click(function(){if(typeof $(this).data("turbolinks-animate-animation")!=="undefined"){TurbolinksAnimate.inline=true}TurbolinksAnimate.options.animation=$(this).data("turbolinks-animate-animation")||b.animation;TurbolinksAnimate.options.appear=$(this).data("turbolinks-animate-appear");TurbolinksAnimate.options.duration=$(this).data("turbolinks-animate-duration")||b.duration;TurbolinksAnimate.options.delay=$(this).data("turbolinks-animate-delay")||b.delay;TurbolinksAnimate.options.type=$(this).data("turbolinks-animate-type")});TurbolinksAnimate.initialized=true;if(b.customListeners==false){TurbolinksAnimate.appear()}};this.setOptions=function(c){var b=TurbolinksAnimate.options.type,d=TurbolinksAnimate.options.appear;TurbolinksAnimate.options={animation:c.animation,duration:c.duration,delay:c.delay,reversedDisappearing:c.reversedDisappearing,breakpoints:c.breakpoints,previousType:b,appear:d}};this.appear=function(){TurbolinksAnimate.disappearing=false;TurbolinksAnimate.toggle()};this.disappear=function(){TurbolinksAnimate.disappearing=true;TurbolinksAnimate.toggle()};this.toggle=function(){if(TurbolinksAnimate.options.animation!="false"){TurbolinksAnimate.resetClasses();TurbolinksAnimate.getElements();TurbolinksAnimate.useOptions();Turbolinks.clearCache();TurbolinksAnimate.animate();TurbolinksAnimate.reset()}};this.getElements=function(){TurbolinksAnimate.elements=[];function b(d){var c=TurbolinksAnimate.options.type||TurbolinksAnimate.options.previousType||"true";if(d.data("turbolinks-animate-persist")==c){return}else{if(d.data("turbolinks-animate-persist-itself")==c||d.find("[data-turbolinks-animate-persist]").length>0||d.find("[data-turbolinks-animate-persist-itself]").length>0){d.children().each(function(){b($(this))})}else{TurbolinksAnimate.elements.push(d)}}}b(TurbolinksAnimate.element)};this.useOptions=function(){if(TurbolinksAnimate.elements!=null){$(TurbolinksAnimate.elements).each(function(){$(this).css("animationDuration",TurbolinksAnimate.options.duration);if(TurbolinksAnimate.options.delay!=false){$(this).css("animationDelay",TurbolinksAnimate.options.delay)}})}};this.reset=function(){delete TurbolinksAnimate.options.appear;delete TurbolinksAnimate.options.previousType;TurbolinksAnimate.inline=false};this.resetClasses=function(){$(TurbolinksAnimate.elements).each(function(){$(this).removeClass(TurbolinksAnimate.animateClasses.join(" "))})};this.animate=function(){$(TurbolinksAnimate.elements).each(function(){$(this).one("webkitAnimationEnd mozAnimationEnd oAnimationEnd oanimationend animationend",function(){setTimeout(function(){if(TurbolinksAnimate.disappearing==false){TurbolinksAnimate.resetClasses()}},250)});$(this).addClass(TurbolinksAnimate.getClassListFor(TurbolinksAnimate.getAnimation()))})};this.getAnimation=function(){var b;if(!TurbolinksAnimate.disappearing){b=TurbolinksAnimate.options.appear}if(TurbolinksAnimate.inline){b=TurbolinksAnimate.options.animation}else{if(typeof TurbolinksAnimate.element.data("turbolinks-animate-animation")!=="undefined"){b=TurbolinksAnimate.element.data("turbolinks-animate-animation")}else{b=TurbolinksAnimate.options.animation}}return b};this.getClassListFor=function(f){var e="animated",d=$(window).width(),c=null;var b=TurbolinksAnimate.options.breakpoints.sort(function(h,g){return g.width-h.width});$.each(b,function(h,g){if(c==null&&d<=g.width){c=f[g.name.toString()]}});if(c==null){c=f}e+=" ";c=$.grep(TurbolinksAnimate.animations,function(g){return g.name.toLowerCase()==c.toLowerCase()})[0];if(TurbolinksAnimate.disappearing){if(c.disappear!=true){c=$.grep(TurbolinksAnimate.animations,function(g){return g.name.toLowerCase()==c.disappear.toLowerCase()})[0]}if(TurbolinksAnimate.options.reversedDisappearing&&c.reverse!=null){e+=c.reverse}else{e+=c.name}}else{e+=c.name}return e}};
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbolinks-animate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Hübotter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-06 00:00:00.000000000 Z
11
+ date: 2018-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: actionpack
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rspec
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -55,7 +69,7 @@ dependencies:
55
69
  description: A dead simple & powerful way of adding rich & adaptive animations to
56
70
  your Rails app which is already using Turbolinks™.
57
71
  email:
58
- - jonas.huebotter@gmail.com
72
+ - me@jonhue.me
59
73
  executables: []
60
74
  extensions: []
61
75
  extra_rdoc_files: []