foundation-rails 6.4.1.0 → 6.4.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Rakefile +5 -6
  4. data/lib/foundation/rails/version.rb +1 -1
  5. data/vendor/assets/js/foundation.abide.js +781 -0
  6. data/vendor/assets/js/foundation.accordion.js +511 -0
  7. data/vendor/assets/js/foundation.accordionMenu.js +527 -0
  8. data/vendor/assets/js/foundation.core.js +860 -0
  9. data/vendor/assets/js/foundation.drilldown.js +759 -0
  10. data/vendor/assets/js/foundation.dropdown.js +1131 -0
  11. data/vendor/assets/js/foundation.dropdownMenu.js +678 -0
  12. data/vendor/assets/js/foundation.equalizer.js +542 -0
  13. data/vendor/assets/js/foundation.interchange.js +399 -0
  14. data/vendor/assets/js/{foundation.js.es6 → foundation.js} +11 -12
  15. data/vendor/assets/js/foundation.magellan.js +449 -0
  16. data/vendor/assets/js/foundation.offcanvas.js +1052 -0
  17. data/vendor/assets/js/foundation.orbit.js +767 -0
  18. data/vendor/assets/js/foundation.responsiveAccordionTabs.js +440 -0
  19. data/vendor/assets/js/foundation.responsiveMenu.js +362 -0
  20. data/vendor/assets/js/foundation.responsiveToggle.js +336 -0
  21. data/vendor/assets/js/foundation.reveal.js +1066 -0
  22. data/vendor/assets/js/foundation.slider.js +1236 -0
  23. data/vendor/assets/js/foundation.smoothScroll.js +303 -0
  24. data/vendor/assets/js/foundation.sticky.js +1001 -0
  25. data/vendor/assets/js/foundation.tabs.js +678 -0
  26. data/vendor/assets/js/foundation.toggler.js +602 -0
  27. data/vendor/assets/js/foundation.tooltip.js +1195 -0
  28. data/vendor/assets/js/{foundation.util.box.js.es6 → foundation.util.box.js} +154 -41
  29. data/vendor/assets/js/foundation.util.imageLoader.js +163 -0
  30. data/vendor/assets/js/foundation.util.keyboard.js +298 -0
  31. data/vendor/assets/js/foundation.util.mediaQuery.js +353 -0
  32. data/vendor/assets/js/foundation.util.motion.js +231 -0
  33. data/vendor/assets/js/foundation.util.nest.js +181 -0
  34. data/vendor/assets/js/foundation.util.timer.js +170 -0
  35. data/vendor/assets/js/foundation.util.timerAndImageLoader.js +90 -0
  36. data/vendor/assets/js/foundation.util.touch.js +275 -0
  37. data/vendor/assets/js/foundation.util.triggers.js +399 -0
  38. data/vendor/assets/js/foundation.zf.responsiveAccordionTabs.js +262 -0
  39. metadata +37 -71
  40. data/vendor/assets/js/entries/foundation-plugins.js +0 -25
  41. data/vendor/assets/js/entries/foundation.js +0 -101
  42. data/vendor/assets/js/entries/plugins/foundation.abide.js +0 -4
  43. data/vendor/assets/js/entries/plugins/foundation.accordion.js +0 -4
  44. data/vendor/assets/js/entries/plugins/foundation.accordionMenu.js +0 -5
  45. data/vendor/assets/js/entries/plugins/foundation.core.js +0 -21
  46. data/vendor/assets/js/entries/plugins/foundation.drilldown.js +0 -4
  47. data/vendor/assets/js/entries/plugins/foundation.dropdown.js +0 -5
  48. data/vendor/assets/js/entries/plugins/foundation.dropdownMenu.js +0 -4
  49. data/vendor/assets/js/entries/plugins/foundation.equalizer.js +0 -4
  50. data/vendor/assets/js/entries/plugins/foundation.interchange.js +0 -4
  51. data/vendor/assets/js/entries/plugins/foundation.magellan.js +0 -4
  52. data/vendor/assets/js/entries/plugins/foundation.offcanvas.js +0 -4
  53. data/vendor/assets/js/entries/plugins/foundation.orbit.js +0 -5
  54. data/vendor/assets/js/entries/plugins/foundation.responsiveAccordionTabs.js +0 -5
  55. data/vendor/assets/js/entries/plugins/foundation.responsiveMenu.js +0 -5
  56. data/vendor/assets/js/entries/plugins/foundation.responsiveToggle.js +0 -5
  57. data/vendor/assets/js/entries/plugins/foundation.reveal.js +0 -4
  58. data/vendor/assets/js/entries/plugins/foundation.slider.js +0 -5
  59. data/vendor/assets/js/entries/plugins/foundation.smoothScroll.js +0 -5
  60. data/vendor/assets/js/entries/plugins/foundation.sticky.js +0 -5
  61. data/vendor/assets/js/entries/plugins/foundation.tabs.js +0 -5
  62. data/vendor/assets/js/entries/plugins/foundation.toggler.js +0 -5
  63. data/vendor/assets/js/entries/plugins/foundation.tooltip.js +0 -4
  64. data/vendor/assets/js/entries/plugins/foundation.util.box.js +0 -4
  65. data/vendor/assets/js/entries/plugins/foundation.util.imageLoader.js +0 -5
  66. data/vendor/assets/js/entries/plugins/foundation.util.keyboard.js +0 -4
  67. data/vendor/assets/js/entries/plugins/foundation.util.mediaQuery.js +0 -4
  68. data/vendor/assets/js/entries/plugins/foundation.util.motion.js +0 -5
  69. data/vendor/assets/js/entries/plugins/foundation.util.nest.js +0 -5
  70. data/vendor/assets/js/entries/plugins/foundation.util.timer.js +0 -5
  71. data/vendor/assets/js/entries/plugins/foundation.util.touch.js +0 -7
  72. data/vendor/assets/js/entries/plugins/foundation.util.triggers.js +0 -5
  73. data/vendor/assets/js/foundation.abide.js.es6 +0 -587
  74. data/vendor/assets/js/foundation.accordion.js.es6 +0 -329
  75. data/vendor/assets/js/foundation.accordionMenu.js.es6 +0 -328
  76. data/vendor/assets/js/foundation.core.js.es6 +0 -337
  77. data/vendor/assets/js/foundation.drilldown.js.es6 +0 -536
  78. data/vendor/assets/js/foundation.dropdown.js.es6 +0 -394
  79. data/vendor/assets/js/foundation.dropdownMenu.js.es6 +0 -458
  80. data/vendor/assets/js/foundation.equalizer.js.es6 +0 -318
  81. data/vendor/assets/js/foundation.interchange.js.es6 +0 -210
  82. data/vendor/assets/js/foundation.magellan.js.es6 +0 -257
  83. data/vendor/assets/js/foundation.offcanvas.js.es6 +0 -546
  84. data/vendor/assets/js/foundation.orbit.js.es6 +0 -531
  85. data/vendor/assets/js/foundation.plugin.js.es6 +0 -54
  86. data/vendor/assets/js/foundation.positionable.js.es6 +0 -206
  87. data/vendor/assets/js/foundation.responsiveAccordionTabs.js.es6 +0 -243
  88. data/vendor/assets/js/foundation.responsiveMenu.js.es6 +0 -155
  89. data/vendor/assets/js/foundation.responsiveToggle.js.es6 +0 -156
  90. data/vendor/assets/js/foundation.reveal.js.es6 +0 -585
  91. data/vendor/assets/js/foundation.slider.js.es6 +0 -712
  92. data/vendor/assets/js/foundation.smoothScroll.js.es6 +0 -135
  93. data/vendor/assets/js/foundation.sticky.js.es6 +0 -507
  94. data/vendor/assets/js/foundation.tabs.js.es6 +0 -498
  95. data/vendor/assets/js/foundation.toggler.js.es6 +0 -150
  96. data/vendor/assets/js/foundation.tooltip.js.es6 +0 -462
  97. data/vendor/assets/js/foundation.util.core.js.es6 +0 -52
  98. data/vendor/assets/js/foundation.util.imageLoader.js.es6 +0 -45
  99. data/vendor/assets/js/foundation.util.keyboard.js.es6 +0 -162
  100. data/vendor/assets/js/foundation.util.mediaQuery.js.es6 +0 -234
  101. data/vendor/assets/js/foundation.util.motion.js.es6 +0 -104
  102. data/vendor/assets/js/foundation.util.nest.js.es6 +0 -67
  103. data/vendor/assets/js/foundation.util.timer.js.es6 +0 -48
  104. data/vendor/assets/js/foundation.util.touch.js.es6 +0 -149
  105. data/vendor/assets/js/foundation.util.triggers.js.es6 +0 -268
@@ -1,135 +0,0 @@
1
- 'use strict';
2
-
3
- import $ from 'jquery';
4
- import { GetYoDigits } from './foundation.util.core';
5
- import { Plugin } from './foundation.plugin';
6
-
7
- /**
8
- * SmoothScroll module.
9
- * @module foundation.smooth-scroll
10
- */
11
- class SmoothScroll extends Plugin {
12
- /**
13
- * Creates a new instance of SmoothScroll.
14
- * @class
15
- * @name SmoothScroll
16
- * @fires SmoothScroll#init
17
- * @param {Object} element - jQuery object to add the trigger to.
18
- * @param {Object} options - Overrides to the default plugin settings.
19
- */
20
- _setup(element, options) {
21
- this.$element = element;
22
- this.options = $.extend({}, SmoothScroll.defaults, this.$element.data(), options);
23
- this.className = 'SmoothScroll'; // ie9 back compat
24
-
25
- this._init();
26
- }
27
-
28
- /**
29
- * Initialize the SmoothScroll plugin
30
- * @private
31
- */
32
- _init() {
33
- var id = this.$element[0].id || GetYoDigits(6, 'smooth-scroll');
34
- var _this = this;
35
- this.$element.attr({
36
- 'id': id
37
- });
38
-
39
- this._events();
40
- }
41
-
42
- /**
43
- * Initializes events for SmoothScroll.
44
- * @private
45
- */
46
- _events() {
47
- var _this = this;
48
-
49
- // click handler function.
50
- var handleLinkClick = function(e) {
51
- // exit function if the event source isn't coming from an anchor with href attribute starts with '#'
52
- if(!$(this).is('a[href^="#"]')) {
53
- return false;
54
- }
55
-
56
- var arrival = this.getAttribute('href');
57
-
58
- _this._inTransition = true;
59
-
60
- SmoothScroll.scrollToLoc(arrival, _this.options, function() {
61
- _this._inTransition = false;
62
- });
63
-
64
- e.preventDefault();
65
- };
66
-
67
- this.$element.on('click.zf.smoothScroll', handleLinkClick)
68
- this.$element.on('click.zf.smoothScroll', 'a[href^="#"]', handleLinkClick);
69
- }
70
-
71
- /**
72
- * Function to scroll to a given location on the page.
73
- * @param {String} loc - A properly formatted jQuery id selector. Example: '#foo'
74
- * @param {Object} options - The options to use.
75
- * @param {Function} callback - The callback function.
76
- * @static
77
- * @function
78
- */
79
- static scrollToLoc(loc, options = SmoothScroll.defaults, callback) {
80
- // Do nothing if target does not exist to prevent errors
81
- if (!$(loc).length) {
82
- return false;
83
- }
84
-
85
- var scrollPos = Math.round($(loc).offset().top - options.threshold / 2 - options.offset);
86
-
87
- $('html, body').stop(true).animate(
88
- { scrollTop: scrollPos },
89
- options.animationDuration,
90
- options.animationEasing,
91
- function() {
92
- if(callback && typeof callback == "function"){
93
- callback();
94
- }
95
- }
96
- );
97
- }
98
- }
99
-
100
- /**
101
- * Default settings for plugin.
102
- */
103
- SmoothScroll.defaults = {
104
- /**
105
- * Amount of time, in ms, the animated scrolling should take between locations.
106
- * @option
107
- * @type {number}
108
- * @default 500
109
- */
110
- animationDuration: 500,
111
- /**
112
- * Animation style to use when scrolling between locations. Can be `'swing'` or `'linear'`.
113
- * @option
114
- * @type {string}
115
- * @default 'linear'
116
- * @see {@link https://api.jquery.com/animate|Jquery animate}
117
- */
118
- animationEasing: 'linear',
119
- /**
120
- * Number of pixels to use as a marker for location changes.
121
- * @option
122
- * @type {number}
123
- * @default 50
124
- */
125
- threshold: 50,
126
- /**
127
- * Number of pixels to offset the scroll of the page on item click if using a sticky nav bar.
128
- * @option
129
- * @type {number}
130
- * @default 0
131
- */
132
- offset: 0
133
- }
134
-
135
- export {SmoothScroll}
@@ -1,507 +0,0 @@
1
- 'use strict';
2
-
3
- import $ from 'jquery';
4
- import { GetYoDigits } from './foundation.util.core';
5
- import { MediaQuery } from './foundation.util.mediaQuery';
6
- import { Plugin } from './foundation.plugin';
7
- import { Triggers } from './foundation.util.triggers';
8
-
9
- /**
10
- * Sticky module.
11
- * @module foundation.sticky
12
- * @requires foundation.util.triggers
13
- * @requires foundation.util.mediaQuery
14
- */
15
-
16
- class Sticky extends Plugin {
17
- /**
18
- * Creates a new instance of a sticky thing.
19
- * @class
20
- * @name Sticky
21
- * @param {jQuery} element - jQuery object to make sticky.
22
- * @param {Object} options - options object passed when creating the element programmatically.
23
- */
24
- _setup(element, options) {
25
- this.$element = element;
26
- this.options = $.extend({}, Sticky.defaults, this.$element.data(), options);
27
- this.className = 'Sticky'; // ie9 back compat
28
-
29
- // Triggers init is idempotent, just need to make sure it is initialized
30
- Triggers.init($);
31
-
32
- this._init();
33
- }
34
-
35
- /**
36
- * Initializes the sticky element by adding classes, getting/setting dimensions, breakpoints and attributes
37
- * @function
38
- * @private
39
- */
40
- _init() {
41
- MediaQuery._init();
42
-
43
- var $parent = this.$element.parent('[data-sticky-container]'),
44
- id = this.$element[0].id || GetYoDigits(6, 'sticky'),
45
- _this = this;
46
-
47
- if($parent.length){
48
- this.$container = $parent;
49
- } else {
50
- this.wasWrapped = true;
51
- this.$element.wrap(this.options.container);
52
- this.$container = this.$element.parent();
53
- }
54
- this.$container.addClass(this.options.containerClass);
55
-
56
- this.$element.addClass(this.options.stickyClass).attr({ 'data-resize': id, 'data-mutate': id });
57
- if (this.options.anchor !== '') {
58
- $('#' + _this.options.anchor).attr({ 'data-mutate': id });
59
- }
60
-
61
- this.scrollCount = this.options.checkEvery;
62
- this.isStuck = false;
63
- $(window).one('load.zf.sticky', function(){
64
- //We calculate the container height to have correct values for anchor points offset calculation.
65
- _this.containerHeight = _this.$element.css("display") == "none" ? 0 : _this.$element[0].getBoundingClientRect().height;
66
- _this.$container.css('height', _this.containerHeight);
67
- _this.elemHeight = _this.containerHeight;
68
- if(_this.options.anchor !== ''){
69
- _this.$anchor = $('#' + _this.options.anchor);
70
- }else{
71
- _this._parsePoints();
72
- }
73
-
74
- _this._setSizes(function(){
75
- var scroll = window.pageYOffset;
76
- _this._calc(false, scroll);
77
- //Unstick the element will ensure that proper classes are set.
78
- if (!_this.isStuck) {
79
- _this._removeSticky((scroll >= _this.topPoint) ? false : true);
80
- }
81
- });
82
- _this._events(id.split('-').reverse().join('-'));
83
- });
84
- }
85
-
86
- /**
87
- * If using multiple elements as anchors, calculates the top and bottom pixel values the sticky thing should stick and unstick on.
88
- * @function
89
- * @private
90
- */
91
- _parsePoints() {
92
- var top = this.options.topAnchor == "" ? 1 : this.options.topAnchor,
93
- btm = this.options.btmAnchor== "" ? document.documentElement.scrollHeight : this.options.btmAnchor,
94
- pts = [top, btm],
95
- breaks = {};
96
- for (var i = 0, len = pts.length; i < len && pts[i]; i++) {
97
- var pt;
98
- if (typeof pts[i] === 'number') {
99
- pt = pts[i];
100
- } else {
101
- var place = pts[i].split(':'),
102
- anchor = $(`#${place[0]}`);
103
-
104
- pt = anchor.offset().top;
105
- if (place[1] && place[1].toLowerCase() === 'bottom') {
106
- pt += anchor[0].getBoundingClientRect().height;
107
- }
108
- }
109
- breaks[i] = pt;
110
- }
111
-
112
-
113
- this.points = breaks;
114
- return;
115
- }
116
-
117
- /**
118
- * Adds event handlers for the scrolling element.
119
- * @private
120
- * @param {String} id - pseudo-random id for unique scroll event listener.
121
- */
122
- _events(id) {
123
- var _this = this,
124
- scrollListener = this.scrollListener = `scroll.zf.${id}`;
125
- if (this.isOn) { return; }
126
- if (this.canStick) {
127
- this.isOn = true;
128
- $(window).off(scrollListener)
129
- .on(scrollListener, function(e) {
130
- if (_this.scrollCount === 0) {
131
- _this.scrollCount = _this.options.checkEvery;
132
- _this._setSizes(function() {
133
- _this._calc(false, window.pageYOffset);
134
- });
135
- } else {
136
- _this.scrollCount--;
137
- _this._calc(false, window.pageYOffset);
138
- }
139
- });
140
- }
141
-
142
- this.$element.off('resizeme.zf.trigger')
143
- .on('resizeme.zf.trigger', function(e, el) {
144
- _this._eventsHandler(id);
145
- });
146
-
147
- this.$element.on('mutateme.zf.trigger', function (e, el) {
148
- _this._eventsHandler(id);
149
- });
150
-
151
- if(this.$anchor) {
152
- this.$anchor.on('mutateme.zf.trigger', function (e, el) {
153
- _this._eventsHandler(id);
154
- });
155
- }
156
- }
157
-
158
- /**
159
- * Handler for events.
160
- * @private
161
- * @param {String} id - pseudo-random id for unique scroll event listener.
162
- */
163
- _eventsHandler(id) {
164
- var _this = this,
165
- scrollListener = this.scrollListener = `scroll.zf.${id}`;
166
-
167
- _this._setSizes(function() {
168
- _this._calc(false);
169
- if (_this.canStick) {
170
- if (!_this.isOn) {
171
- _this._events(id);
172
- }
173
- } else if (_this.isOn) {
174
- _this._pauseListeners(scrollListener);
175
- }
176
- });
177
- }
178
-
179
- /**
180
- * Removes event handlers for scroll and change events on anchor.
181
- * @fires Sticky#pause
182
- * @param {String} scrollListener - unique, namespaced scroll listener attached to `window`
183
- */
184
- _pauseListeners(scrollListener) {
185
- this.isOn = false;
186
- $(window).off(scrollListener);
187
-
188
- /**
189
- * Fires when the plugin is paused due to resize event shrinking the view.
190
- * @event Sticky#pause
191
- * @private
192
- */
193
- this.$element.trigger('pause.zf.sticky');
194
- }
195
-
196
- /**
197
- * Called on every `scroll` event and on `_init`
198
- * fires functions based on booleans and cached values
199
- * @param {Boolean} checkSizes - true if plugin should recalculate sizes and breakpoints.
200
- * @param {Number} scroll - current scroll position passed from scroll event cb function. If not passed, defaults to `window.pageYOffset`.
201
- */
202
- _calc(checkSizes, scroll) {
203
- if (checkSizes) { this._setSizes(); }
204
-
205
- if (!this.canStick) {
206
- if (this.isStuck) {
207
- this._removeSticky(true);
208
- }
209
- return false;
210
- }
211
-
212
- if (!scroll) { scroll = window.pageYOffset; }
213
-
214
- if (scroll >= this.topPoint) {
215
- if (scroll <= this.bottomPoint) {
216
- if (!this.isStuck) {
217
- this._setSticky();
218
- }
219
- } else {
220
- if (this.isStuck) {
221
- this._removeSticky(false);
222
- }
223
- }
224
- } else {
225
- if (this.isStuck) {
226
- this._removeSticky(true);
227
- }
228
- }
229
- }
230
-
231
- /**
232
- * Causes the $element to become stuck.
233
- * Adds `position: fixed;`, and helper classes.
234
- * @fires Sticky#stuckto
235
- * @function
236
- * @private
237
- */
238
- _setSticky() {
239
- var _this = this,
240
- stickTo = this.options.stickTo,
241
- mrgn = stickTo === 'top' ? 'marginTop' : 'marginBottom',
242
- notStuckTo = stickTo === 'top' ? 'bottom' : 'top',
243
- css = {};
244
-
245
- css[mrgn] = `${this.options[mrgn]}em`;
246
- css[stickTo] = 0;
247
- css[notStuckTo] = 'auto';
248
- this.isStuck = true;
249
- this.$element.removeClass(`is-anchored is-at-${notStuckTo}`)
250
- .addClass(`is-stuck is-at-${stickTo}`)
251
- .css(css)
252
- /**
253
- * Fires when the $element has become `position: fixed;`
254
- * Namespaced to `top` or `bottom`, e.g. `sticky.zf.stuckto:top`
255
- * @event Sticky#stuckto
256
- */
257
- .trigger(`sticky.zf.stuckto:${stickTo}`);
258
- this.$element.on("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd", function() {
259
- _this._setSizes();
260
- });
261
- }
262
-
263
- /**
264
- * Causes the $element to become unstuck.
265
- * Removes `position: fixed;`, and helper classes.
266
- * Adds other helper classes.
267
- * @param {Boolean} isTop - tells the function if the $element should anchor to the top or bottom of its $anchor element.
268
- * @fires Sticky#unstuckfrom
269
- * @private
270
- */
271
- _removeSticky(isTop) {
272
- var stickTo = this.options.stickTo,
273
- stickToTop = stickTo === 'top',
274
- css = {},
275
- anchorPt = (this.points ? this.points[1] - this.points[0] : this.anchorHeight) - this.elemHeight,
276
- mrgn = stickToTop ? 'marginTop' : 'marginBottom',
277
- notStuckTo = stickToTop ? 'bottom' : 'top',
278
- topOrBottom = isTop ? 'top' : 'bottom';
279
-
280
- css[mrgn] = 0;
281
-
282
- css['bottom'] = 'auto';
283
- if(isTop) {
284
- css['top'] = 0;
285
- } else {
286
- css['top'] = anchorPt;
287
- }
288
-
289
- this.isStuck = false;
290
- this.$element.removeClass(`is-stuck is-at-${stickTo}`)
291
- .addClass(`is-anchored is-at-${topOrBottom}`)
292
- .css(css)
293
- /**
294
- * Fires when the $element has become anchored.
295
- * Namespaced to `top` or `bottom`, e.g. `sticky.zf.unstuckfrom:bottom`
296
- * @event Sticky#unstuckfrom
297
- */
298
- .trigger(`sticky.zf.unstuckfrom:${topOrBottom}`);
299
- }
300
-
301
- /**
302
- * Sets the $element and $container sizes for plugin.
303
- * Calls `_setBreakPoints`.
304
- * @param {Function} cb - optional callback function to fire on completion of `_setBreakPoints`.
305
- * @private
306
- */
307
- _setSizes(cb) {
308
- this.canStick = MediaQuery.is(this.options.stickyOn);
309
- if (!this.canStick) {
310
- if (cb && typeof cb === 'function') { cb(); }
311
- }
312
- var _this = this,
313
- newElemWidth = this.$container[0].getBoundingClientRect().width,
314
- comp = window.getComputedStyle(this.$container[0]),
315
- pdngl = parseInt(comp['padding-left'], 10),
316
- pdngr = parseInt(comp['padding-right'], 10);
317
-
318
- if (this.$anchor && this.$anchor.length) {
319
- this.anchorHeight = this.$anchor[0].getBoundingClientRect().height;
320
- } else {
321
- this._parsePoints();
322
- }
323
-
324
- this.$element.css({
325
- 'max-width': `${newElemWidth - pdngl - pdngr}px`
326
- });
327
-
328
- var newContainerHeight = this.$element[0].getBoundingClientRect().height || this.containerHeight;
329
- if (this.$element.css("display") == "none") {
330
- newContainerHeight = 0;
331
- }
332
- this.containerHeight = newContainerHeight;
333
- this.$container.css({
334
- height: newContainerHeight
335
- });
336
- this.elemHeight = newContainerHeight;
337
-
338
- if (!this.isStuck) {
339
- if (this.$element.hasClass('is-at-bottom')) {
340
- var anchorPt = (this.points ? this.points[1] - this.$container.offset().top : this.anchorHeight) - this.elemHeight;
341
- this.$element.css('top', anchorPt);
342
- }
343
- }
344
-
345
- this._setBreakPoints(newContainerHeight, function() {
346
- if (cb && typeof cb === 'function') { cb(); }
347
- });
348
- }
349
-
350
- /**
351
- * Sets the upper and lower breakpoints for the element to become sticky/unsticky.
352
- * @param {Number} elemHeight - px value for sticky.$element height, calculated by `_setSizes`.
353
- * @param {Function} cb - optional callback function to be called on completion.
354
- * @private
355
- */
356
- _setBreakPoints(elemHeight, cb) {
357
- if (!this.canStick) {
358
- if (cb && typeof cb === 'function') { cb(); }
359
- else { return false; }
360
- }
361
- var mTop = emCalc(this.options.marginTop),
362
- mBtm = emCalc(this.options.marginBottom),
363
- topPoint = this.points ? this.points[0] : this.$anchor.offset().top,
364
- bottomPoint = this.points ? this.points[1] : topPoint + this.anchorHeight,
365
- // topPoint = this.$anchor.offset().top || this.points[0],
366
- // bottomPoint = topPoint + this.anchorHeight || this.points[1],
367
- winHeight = window.innerHeight;
368
-
369
- if (this.options.stickTo === 'top') {
370
- topPoint -= mTop;
371
- bottomPoint -= (elemHeight + mTop);
372
- } else if (this.options.stickTo === 'bottom') {
373
- topPoint -= (winHeight - (elemHeight + mBtm));
374
- bottomPoint -= (winHeight - mBtm);
375
- } else {
376
- //this would be the stickTo: both option... tricky
377
- }
378
-
379
- this.topPoint = topPoint;
380
- this.bottomPoint = bottomPoint;
381
-
382
- if (cb && typeof cb === 'function') { cb(); }
383
- }
384
-
385
- /**
386
- * Destroys the current sticky element.
387
- * Resets the element to the top position first.
388
- * Removes event listeners, JS-added css properties and classes, and unwraps the $element if the JS added the $container.
389
- * @function
390
- */
391
- _destroy() {
392
- this._removeSticky(true);
393
-
394
- this.$element.removeClass(`${this.options.stickyClass} is-anchored is-at-top`)
395
- .css({
396
- height: '',
397
- top: '',
398
- bottom: '',
399
- 'max-width': ''
400
- })
401
- .off('resizeme.zf.trigger')
402
- .off('mutateme.zf.trigger');
403
- if (this.$anchor && this.$anchor.length) {
404
- this.$anchor.off('change.zf.sticky');
405
- }
406
- $(window).off(this.scrollListener);
407
-
408
- if (this.wasWrapped) {
409
- this.$element.unwrap();
410
- } else {
411
- this.$container.removeClass(this.options.containerClass)
412
- .css({
413
- height: ''
414
- });
415
- }
416
- }
417
- }
418
-
419
- Sticky.defaults = {
420
- /**
421
- * Customizable container template. Add your own classes for styling and sizing.
422
- * @option
423
- * @type {string}
424
- * @default '&lt;div data-sticky-container&gt;&lt;/div&gt;'
425
- */
426
- container: '<div data-sticky-container></div>',
427
- /**
428
- * Location in the view the element sticks to. Can be `'top'` or `'bottom'`.
429
- * @option
430
- * @type {string}
431
- * @default 'top'
432
- */
433
- stickTo: 'top',
434
- /**
435
- * If anchored to a single element, the id of that element.
436
- * @option
437
- * @type {string}
438
- * @default ''
439
- */
440
- anchor: '',
441
- /**
442
- * If using more than one element as anchor points, the id of the top anchor.
443
- * @option
444
- * @type {string}
445
- * @default ''
446
- */
447
- topAnchor: '',
448
- /**
449
- * If using more than one element as anchor points, the id of the bottom anchor.
450
- * @option
451
- * @type {string}
452
- * @default ''
453
- */
454
- btmAnchor: '',
455
- /**
456
- * Margin, in `em`'s to apply to the top of the element when it becomes sticky.
457
- * @option
458
- * @type {number}
459
- * @default 1
460
- */
461
- marginTop: 1,
462
- /**
463
- * Margin, in `em`'s to apply to the bottom of the element when it becomes sticky.
464
- * @option
465
- * @type {number}
466
- * @default 1
467
- */
468
- marginBottom: 1,
469
- /**
470
- * Breakpoint string that is the minimum screen size an element should become sticky.
471
- * @option
472
- * @type {string}
473
- * @default 'medium'
474
- */
475
- stickyOn: 'medium',
476
- /**
477
- * Class applied to sticky element, and removed on destruction. Foundation defaults to `sticky`.
478
- * @option
479
- * @type {string}
480
- * @default 'sticky'
481
- */
482
- stickyClass: 'sticky',
483
- /**
484
- * Class applied to sticky container. Foundation defaults to `sticky-container`.
485
- * @option
486
- * @type {string}
487
- * @default 'sticky-container'
488
- */
489
- containerClass: 'sticky-container',
490
- /**
491
- * Number of scroll events between the plugin's recalculating sticky points. Setting it to `0` will cause it to recalc every scroll event, setting it to `-1` will prevent recalc on scroll.
492
- * @option
493
- * @type {number}
494
- * @default -1
495
- */
496
- checkEvery: -1
497
- };
498
-
499
- /**
500
- * Helper function to calculate em values
501
- * @param Number {em} - number of em's to calculate into pixels
502
- */
503
- function emCalc(em) {
504
- return parseInt(window.getComputedStyle(document.body, null).fontSize, 10) * em;
505
- }
506
-
507
- export {Sticky};