@brandocms/jupiter 3.46.4 → 3.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/package.json +9 -9
  2. package/src/events/index.js +1 -0
  3. package/src/index.js +7 -7
  4. package/src/modules/Application/index.js +119 -80
  5. package/src/modules/Breakpoints/index.js +14 -17
  6. package/src/modules/Cookies/index.js +86 -43
  7. package/src/modules/CoverOverlay/index.js +6 -3
  8. package/src/modules/Dataloader/index.js +173 -7
  9. package/src/modules/Dom/index.js +26 -26
  10. package/src/modules/Dropdown/index.js +14 -14
  11. package/src/modules/EqualHeightElements/index.js +70 -0
  12. package/src/modules/EqualHeightImages/index.js +95 -0
  13. package/src/modules/FeatureTests/index.js +22 -15
  14. package/src/modules/FixedHeader/index.js +79 -75
  15. package/src/modules/Fontloader/index.js +5 -3
  16. package/src/modules/FooterReveal/index.js +1 -1
  17. package/src/modules/HeroSlider/index.js +33 -23
  18. package/src/modules/HeroVideo/index.js +15 -13
  19. package/src/modules/Lazyload/index.js +119 -65
  20. package/src/modules/Lightbox/index.js +40 -43
  21. package/src/modules/Links/index.js +8 -7
  22. package/src/modules/Marquee/index.js +47 -37
  23. package/src/modules/MobileMenu/index.js +112 -65
  24. package/src/modules/Moonwalk/index.js +256 -203
  25. package/src/modules/Parallax/index.js +24 -14
  26. package/src/modules/Popup/index.js +24 -21
  27. package/src/modules/ScrollSpy/index.js +5 -5
  28. package/src/modules/StackedBoxes/index.js +5 -5
  29. package/src/modules/StickyHeader/index.js +73 -70
  30. package/src/modules/Toggler/index.js +2 -2
  31. package/src/modules/Typography/index.js +13 -10
  32. package/src/utils/dispatchElementEvent.js +2 -2
  33. package/src/utils/imageIsLoaded.js +1 -1
  34. package/src/utils/imagesAreLoaded.js +3 -3
  35. package/src/utils/loadScript.js +9 -8
  36. package/src/utils/rafCallback.js +12 -10
  37. package/src/utils/zoom.js +11 -8
@@ -0,0 +1,70 @@
1
+ import { gsap } from 'gsap'
2
+ import Dom from '../Dom'
3
+ import _defaultsDeep from 'lodash.defaultsdeep'
4
+ import * as Events from '../../events'
5
+
6
+ const DEFAULT_OPTIONS = {}
7
+
8
+ export default class EqualHeightElements {
9
+ constructor(app, selector, opts = {}, container = document.body) {
10
+ this.app = app
11
+ this.container = container
12
+ this.opts = _defaultsDeep(opts, DEFAULT_OPTIONS)
13
+ this.selector = selector
14
+ this.initialize()
15
+ window.addEventListener(Events.APPLICATION_RESIZE, () => {
16
+ gsap.set('[data-eq-height-elements-adjusted]', { clearProps: 'minHeight' })
17
+ this.initialize()
18
+ })
19
+ }
20
+
21
+ initialize() {
22
+ const canvases = Dom.all(this.container, '[data-eq-height-elements]')
23
+ Array.from(canvases).forEach(canvas => {
24
+ let lastTop = null
25
+ const actionables = []
26
+ let elements = []
27
+ let height = 0
28
+ const eqElements = Dom.all(canvas, this.selector)
29
+
30
+ eqElements.forEach(el => {
31
+ const rect = el.getBoundingClientRect()
32
+
33
+ if (lastTop === null) {
34
+ height = rect.height
35
+ elements.push(el)
36
+ lastTop = rect.top
37
+ return
38
+ }
39
+
40
+ if (lastTop !== rect.top) {
41
+ console.debug('== pushing actionables', { elements, height })
42
+ actionables.push({ elements, height })
43
+ elements = []
44
+ height = rect.height
45
+ } else if (lastTop === rect.top) {
46
+ if (rect.height > height) {
47
+ height = rect.height
48
+ }
49
+ } else {
50
+ height = rect.height
51
+ }
52
+ elements.push(el)
53
+ lastTop = rect.top
54
+ })
55
+
56
+ if (elements.length) {
57
+ actionables.push({ elements, height })
58
+ }
59
+
60
+ if (actionables.length) {
61
+ actionables.forEach(a => {
62
+ gsap.set(a.elements, {
63
+ minHeight: a.height,
64
+ attr: { 'data-eq-height-elements-adjusted': true }
65
+ })
66
+ })
67
+ }
68
+ })
69
+ }
70
+ }
@@ -0,0 +1,95 @@
1
+ import { gsap } from 'gsap'
2
+ import Dom from '../Dom'
3
+ import imagesAreLoaded from '../../utils/imagesAreLoaded'
4
+ import _defaultsDeep from 'lodash.defaultsdeep'
5
+
6
+ const DEFAULT_OPTIONS = {}
7
+
8
+ export default class EqualHeightImages {
9
+ constructor(app, opts = {}, container = document.body) {
10
+ this.app = app
11
+ this.container = container
12
+ this.opts = _defaultsDeep(opts, DEFAULT_OPTIONS)
13
+ this.initialize()
14
+ }
15
+
16
+ initialize() {
17
+ const canvases = Dom.all(this.container, '[data-eq-height-images]')
18
+ Array.from(canvases).forEach(canvas => {
19
+ let lastTop = null
20
+ const actionables = []
21
+ let elements = []
22
+ let height = 0
23
+ const imgs = Dom.all(canvas, 'img')
24
+
25
+ imagesAreLoaded(imgs, false).then(() => {
26
+ imgs.forEach(el => {
27
+ const rect = el.getBoundingClientRect()
28
+ const size = this.getImgSizeInfo(el)
29
+
30
+ if (lastTop === null) {
31
+ height = size.height
32
+ elements.push(el)
33
+ lastTop = rect.top
34
+ return
35
+ }
36
+
37
+ if (lastTop !== rect.top) {
38
+ actionables.push({ elements, height })
39
+ elements = []
40
+ height = size.height
41
+ } else if (lastTop === rect.top) {
42
+ if (size.height > height) {
43
+ height = size.height
44
+ }
45
+ } else {
46
+ height = size.height
47
+ }
48
+ elements.push(el)
49
+ lastTop = rect.top
50
+ })
51
+
52
+ if (elements.length) {
53
+ actionables.push({ elements, height })
54
+ }
55
+
56
+ if (actionables.length) {
57
+ actionables.forEach(a => {
58
+ gsap.set(a.elements, { minHeight: a.height })
59
+ })
60
+ }
61
+ })
62
+ })
63
+ }
64
+
65
+ getRenderedSize(contains, cWidth, cHeight, width, height, pos) {
66
+ const oRatio = width / height
67
+ const cRatio = cWidth / cHeight
68
+ // eslint-disable-next-line func-names
69
+ return function () {
70
+ if (contains ? oRatio > cRatio : oRatio < cRatio) {
71
+ this.width = cWidth
72
+ this.height = cWidth / oRatio
73
+ } else {
74
+ this.width = cHeight * oRatio
75
+ this.height = cHeight
76
+ }
77
+ this.left = (cWidth - this.width) * (pos / 100)
78
+ this.right = this.width + this.left
79
+ return this
80
+ }.call({})
81
+ }
82
+
83
+ getImgSizeInfo(img) {
84
+ const pos = window.getComputedStyle(img).getPropertyValue('object-position').split(' ')
85
+
86
+ return this.getRenderedSize(
87
+ true,
88
+ img.width,
89
+ img.height,
90
+ img.naturalWidth,
91
+ img.naturalHeight,
92
+ parseInt(pos[0])
93
+ )
94
+ }
95
+ }
@@ -1,7 +1,7 @@
1
1
  import * as Events from '../../events'
2
2
 
3
3
  export default class FeatureTests {
4
- constructor (app, tests) {
4
+ constructor(app, tests) {
5
5
  this.app = app
6
6
 
7
7
  this.testFns = {
@@ -40,13 +40,13 @@ export default class FeatureTests {
40
40
  this.bindEventTests()
41
41
  }
42
42
 
43
- runTests (tests) {
43
+ runTests(tests) {
44
44
  tests.forEach(test => {
45
45
  this.testFor(test, this.testFns[test]())
46
46
  })
47
47
  }
48
48
 
49
- testFor (feature, result) {
49
+ testFor(feature, result) {
50
50
  this.results[feature] = result
51
51
  document.documentElement.setAttribute(`data-${feature}`, result)
52
52
  }
@@ -55,7 +55,7 @@ export default class FeatureTests {
55
55
  * Check if we should outline elements. If the user hits TAB, we should outline,
56
56
  * otherwise we skip it.
57
57
  */
58
- testOutlineEvents () {
58
+ testOutlineEvents() {
59
59
  document.addEventListener('mousedown', () => {
60
60
  this.testFor('outline', false)
61
61
  })
@@ -73,7 +73,7 @@ export default class FeatureTests {
73
73
  * Sometimes the initial test for touch/mouse fail, so
74
74
  * listen for events as well
75
75
  */
76
- testTouchMouseEvents () {
76
+ testTouchMouseEvents() {
77
77
  const onTouchStart = () => {
78
78
  if (!this.results.touch) {
79
79
  this.results.touch = true
@@ -93,7 +93,7 @@ export default class FeatureTests {
93
93
 
94
94
  const onMouseMove = () => {
95
95
  if (!this.results.mouse) {
96
- if ((Date.now() - this.devicelastTouched) > 300) {
96
+ if (Date.now() - this.devicelastTouched > 300) {
97
97
  this.results.touch = false
98
98
  this.results.mouse = true
99
99
  this.testFor('touch', false)
@@ -105,24 +105,29 @@ export default class FeatureTests {
105
105
  document.addEventListener('mousemove', onMouseMove, false)
106
106
  }
107
107
 
108
- bindEventTests () {
108
+ bindEventTests() {
109
109
  this.testOutlineEvents()
110
110
  this.testTouchMouseEvents()
111
111
  }
112
112
 
113
- testTouch () {
114
- return ('ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0)
113
+ testTouch() {
114
+ return (
115
+ 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0
116
+ )
115
117
  }
116
118
 
117
- testIE11 () {
118
- return '-ms-scroll-limit' in document.documentElement.style && '-ms-ime-align' in document.documentElement.style
119
+ testIE11() {
120
+ return (
121
+ '-ms-scroll-limit' in document.documentElement.style &&
122
+ '-ms-ime-align' in document.documentElement.style
123
+ )
119
124
  }
120
125
 
121
- testIOS () {
126
+ testIOS() {
122
127
  return navigator.userAgent.match(/iphone|ipod|ipad/i)
123
128
  }
124
129
 
125
- testBrowsers () {
130
+ testBrowsers() {
126
131
  let browser = 'unknown'
127
132
  let isChrome = false
128
133
  let isSafari = false
@@ -140,12 +145,14 @@ export default class FeatureTests {
140
145
  browser = 'safari'
141
146
  isSafari = true
142
147
  }
143
- if ((isChrome) && (isSafari)) { browser = 'chrome' }
148
+ if (isChrome && isSafari) {
149
+ browser = 'chrome'
150
+ }
144
151
 
145
152
  return browser
146
153
  }
147
154
 
148
- testWebview () {
155
+ testWebview() {
149
156
  return navigator.userAgent.match(/FBAN|FBAV|instagram|facebook|messenger/i)
150
157
  }
151
158
  }
@@ -82,11 +82,11 @@ const DEFAULT_EVENTS = {
82
82
  // eslint-disable-next-line no-unused-vars
83
83
  onNotBottom: h => {},
84
84
  // eslint-disable-next-line no-unused-vars
85
- onMobileMenuOpen: h => { },
85
+ onMobileMenuOpen: h => {},
86
86
  // eslint-disable-next-line no-unused-vars
87
- onMobileMenuClose: h => { },
87
+ onMobileMenuClose: h => {},
88
88
  // eslint-disable-next-line no-unused-vars
89
- onIntersect: h => { },
89
+ onIntersect: h => {},
90
90
  onOutline: h => {
91
91
  h.preventUnpin = true
92
92
  h.pin()
@@ -105,9 +105,7 @@ const DEFAULT_OPTIONS = {
105
105
  intersects: null,
106
106
  beforeEnter: h => {
107
107
  const timeline = gsap.timeline()
108
- timeline
109
- .set(h.el, { yPercent: -100 })
110
- .set(h.lis, { opacity: 0 })
108
+ timeline.set(h.el, { yPercent: -100 }).set(h.lis, { opacity: 0 })
111
109
  },
112
110
 
113
111
  enter: h => {
@@ -135,7 +133,7 @@ const DEFAULT_OPTIONS = {
135
133
  }
136
134
 
137
135
  export default class FixedHeader {
138
- constructor (app, opts = {}) {
136
+ constructor(app, opts = {}) {
139
137
  this.app = app
140
138
  this.mainOpts = _defaultsDeep(opts, DEFAULT_OPTIONS)
141
139
 
@@ -183,7 +181,7 @@ export default class FixedHeader {
183
181
  this.initialize()
184
182
  }
185
183
 
186
- initialize () {
184
+ initialize() {
187
185
  // bind to canvas scroll
188
186
  this.lastKnownScrollY = this.getScrollY()
189
187
  this.lastKnownScrollHeight = document.body.scrollHeight
@@ -216,21 +214,25 @@ export default class FixedHeader {
216
214
  }
217
215
 
218
216
  if (this.mainOpts.unpinOnForcedScrollStart) {
219
- window.addEventListener(Events.APPLICATION_FORCED_SCROLL_START, this.unpin.bind(this), false)
217
+ window.addEventListener(
218
+ Events.APPLICATION_FORCED_SCROLL_START,
219
+ this.unpin.bind(this),
220
+ false
221
+ )
220
222
  }
221
223
 
222
224
  if (this.mainOpts.pinOnForcedScrollEnd) {
223
225
  window.addEventListener(Events.APPLICATION_FORCED_SCROLL_END, this.pin.bind(this), false)
224
226
  }
225
227
 
226
- window.addEventListener(Events.APPLICATION_REVEALED, e => {
228
+ this.app.registerCallback(Events.APPLICATION_REVEALED, () => {
227
229
  window.addEventListener(Events.APPLICATION_SCROLL, this.update.bind(this), {
228
230
  capture: false,
229
231
  passive: true
230
232
  })
231
233
  })
232
234
 
233
- window.addEventListener(Events.APPLICATION_READY, this.unpinIfScrolled.bind(this))
235
+ this.app.registerCallback(Events.APPLICATION_READY, this.unpinIfScrolled.bind(this))
234
236
 
235
237
  this.preflight()
236
238
 
@@ -246,34 +248,37 @@ export default class FixedHeader {
246
248
  this.opts.beforeEnter(this)
247
249
  }
248
250
 
249
- preflight () {
251
+ preflight() {
250
252
  this.checkSize(true)
251
253
  this.checkBg(true)
252
254
  this.checkTop(true)
253
255
 
254
- window.addEventListener(Events.APPLICATION_REVEALED, e => {
256
+ this.app.registerCallback(Events.APPLICATION_REVEALED, () => {
255
257
  setTimeout(() => {
256
258
  this.el.setAttribute('data-header-transitions', '')
257
259
  }, 350)
258
260
  })
259
261
  }
260
262
 
261
- lock () {
263
+ lock() {
262
264
  this.preventPin = true
263
265
  this.preventUnpin = true
264
266
  }
265
267
 
266
- unlock () {
268
+ unlock() {
267
269
  this.preventPin = false
268
270
  this.preventUnpin = false
269
271
  }
270
272
 
271
- isScrolled () {
272
- return (window.pageYOffset
273
- || document.documentElement.scrollTop) - (document.documentElement.clientTop || 0) > 0
273
+ isScrolled() {
274
+ return (
275
+ (window.pageYOffset || document.documentElement.scrollTop) -
276
+ (document.documentElement.clientTop || 0) >
277
+ 0
278
+ )
274
279
  }
275
280
 
276
- unpinIfScrolled () {
281
+ unpinIfScrolled() {
277
282
  if (this.isScrolled()) {
278
283
  // page is scrolled on ready -- ensure we unpin
279
284
  this.pageIsScrolledOnReady = true
@@ -281,7 +286,7 @@ export default class FixedHeader {
281
286
  }
282
287
  }
283
288
 
284
- enter () {
289
+ enter() {
285
290
  if (this.opts.enter) {
286
291
  this.checkSize(true)
287
292
  this.checkBg(true)
@@ -290,7 +295,7 @@ export default class FixedHeader {
290
295
  }
291
296
  }
292
297
 
293
- setResizeTimer () {
298
+ setResizeTimer() {
294
299
  this._isResizing = true
295
300
  if (this._pinned) {
296
301
  // unpin if resizing to prevent visual clutter.
@@ -307,11 +312,11 @@ export default class FixedHeader {
307
312
  }, 500)
308
313
  }
309
314
 
310
- update () {
315
+ update() {
311
316
  this.redraw()
312
317
  }
313
318
 
314
- checkSize (force) {
319
+ checkSize(force) {
315
320
  if (this.currentScrollY > this.opts.offsetSmall) {
316
321
  if (force) {
317
322
  this.small()
@@ -325,7 +330,7 @@ export default class FixedHeader {
325
330
  }
326
331
  }
327
332
 
328
- checkBg (force) {
333
+ checkBg(force) {
329
334
  if (this.currentScrollY > this.opts.offsetBg) {
330
335
  if (force) {
331
336
  this.altBg()
@@ -339,7 +344,7 @@ export default class FixedHeader {
339
344
  }
340
345
  }
341
346
 
342
- checkTop (force) {
347
+ checkTop(force) {
343
348
  if (this.currentScrollY <= this.opts.offset) {
344
349
  if (force) {
345
350
  this.top()
@@ -353,7 +358,7 @@ export default class FixedHeader {
353
358
  }
354
359
  }
355
360
 
356
- checkBot (force) {
361
+ checkBot(force) {
357
362
  if (this.currentScrollY + this.getViewportHeight() >= this.getScrollerHeight()) {
358
363
  if (force) {
359
364
  this.bottom()
@@ -367,7 +372,7 @@ export default class FixedHeader {
367
372
  }
368
373
  }
369
374
 
370
- checkPin (force, toleranceExceeded) {
375
+ checkPin(force, toleranceExceeded) {
371
376
  if (this.shouldUnpin(toleranceExceeded)) {
372
377
  if (this.mobileMenuOpen) {
373
378
  return
@@ -386,12 +391,13 @@ export default class FixedHeader {
386
391
  }
387
392
  }
388
393
 
389
- redraw () {
394
+ redraw() {
390
395
  this.currentScrollY = this.getScrollY()
391
396
  this.currentScrollHeight = document.body.scrollHeight
392
397
  const toleranceExceeded = this.toleranceExceeded()
393
398
 
394
- if (this.isOutOfBounds()) { // Ignore bouncy scrolling in OSX
399
+ if (this.isOutOfBounds()) {
400
+ // Ignore bouncy scrolling in OSX
395
401
  return
396
402
  }
397
403
 
@@ -415,35 +421,35 @@ export default class FixedHeader {
415
421
  this._firstLoad = false
416
422
  }
417
423
 
418
- notTop () {
424
+ notTop() {
419
425
  this._top = false
420
426
  this.el.removeAttribute('data-header-top')
421
427
  this.el.setAttribute('data-header-not-top', '')
422
428
  this.opts.onNotTop(this)
423
429
  }
424
430
 
425
- top () {
431
+ top() {
426
432
  this._top = true
427
433
  this.el.setAttribute('data-header-top', '')
428
434
  this.el.removeAttribute('data-header-not-top')
429
435
  this.opts.onTop(this)
430
436
  }
431
437
 
432
- notBottom () {
438
+ notBottom() {
433
439
  this._bottom = false
434
440
  this.el.setAttribute('data-header-not-bottom', '')
435
441
  this.el.removeAttribute('data-header-bottom')
436
442
  this.opts.onNotBottom(this)
437
443
  }
438
444
 
439
- bottom () {
445
+ bottom() {
440
446
  this._bottom = true
441
447
  this.el.setAttribute('data-header-bottom', '')
442
448
  this.el.removeAttribute('data-header-not-bottom')
443
449
  this.opts.onBottom(this)
444
450
  }
445
451
 
446
- unpin () {
452
+ unpin() {
447
453
  if (this.preventUnpin) {
448
454
  return
449
455
  }
@@ -453,7 +459,7 @@ export default class FixedHeader {
453
459
  this.opts.onUnpin(this)
454
460
  }
455
461
 
456
- pin () {
462
+ pin() {
457
463
  if (this.preventPin) {
458
464
  return
459
465
  }
@@ -463,42 +469,42 @@ export default class FixedHeader {
463
469
  this.opts.onPin(this)
464
470
  }
465
471
 
466
- notSmall () {
472
+ notSmall() {
467
473
  this._small = false
468
474
  this.el.setAttribute('data-header-big', '')
469
475
  this.el.removeAttribute('data-header-small')
470
476
  this.opts.onNotSmall(this)
471
477
  }
472
478
 
473
- small () {
479
+ small() {
474
480
  this._small = true
475
481
  this.el.setAttribute('data-header-small', '')
476
482
  this.el.removeAttribute('data-header-big')
477
483
  this.opts.onSmall(this)
478
484
  }
479
485
 
480
- notAltBg () {
486
+ notAltBg() {
481
487
  this._altBg = false
482
488
  this.el.setAttribute('data-header-reg-bg', '')
483
489
  this.el.removeAttribute('data-header-alt-bg')
484
490
  this.opts.onNotAltBg(this)
485
491
  }
486
492
 
487
- altBg () {
493
+ altBg() {
488
494
  this._altBg = true
489
495
  this.el.setAttribute('data-header-alt-bg', '')
490
496
  this.el.removeAttribute('data-header-reg-bg')
491
497
  this.opts.onAltBg(this)
492
498
  }
493
499
 
494
- shouldUnpin (toleranceExceeded) {
500
+ shouldUnpin(toleranceExceeded) {
495
501
  const scrollingDown = this.currentScrollY > this.lastKnownScrollY
496
502
  const pastOffset = this.currentScrollY >= this.opts.offset
497
503
 
498
504
  return scrollingDown && pastOffset && toleranceExceeded
499
505
  }
500
506
 
501
- shouldPin (toleranceExceeded) {
507
+ shouldPin(toleranceExceeded) {
502
508
  if (this._isResizing) {
503
509
  return false
504
510
  }
@@ -509,60 +515,55 @@ export default class FixedHeader {
509
515
  return (scrollingUp && toleranceExceeded) || pastOffset
510
516
  }
511
517
 
512
- isOutOfBounds () {
518
+ isOutOfBounds() {
513
519
  const pastTop = this.currentScrollY < 0
514
- const pastBottom = this.currentScrollY
515
- + this.getScrollerPhysicalHeight()
516
- > this.getScrollerHeight()
520
+ const pastBottom =
521
+ this.currentScrollY + this.getScrollerPhysicalHeight() > this.getScrollerHeight()
517
522
 
518
523
  return pastTop || pastBottom
519
524
  }
520
525
 
521
- getScrollerPhysicalHeight () {
522
- return (this.opts.canvas === window || this.opts.canvas === document.body)
526
+ getScrollerPhysicalHeight() {
527
+ return this.opts.canvas === window || this.opts.canvas === document.body
523
528
  ? this.getViewportHeight()
524
529
  : this.getElementPhysicalHeight(this.opts.canvas)
525
530
  }
526
531
 
527
- getScrollerHeight () {
528
- return (this.opts.canvas === window || this.opts.canvas === document.body)
532
+ getScrollerHeight() {
533
+ return this.opts.canvas === window || this.opts.canvas === document.body
529
534
  ? this.getDocumentHeight()
530
535
  : this.getElementHeight(this.opts.canvas)
531
536
  }
532
537
 
533
- getDocumentHeight () {
538
+ getDocumentHeight() {
534
539
  const { body } = document
535
540
  const { documentElement } = document
536
541
 
537
542
  return Math.max(
538
- body.scrollHeight, documentElement.scrollHeight,
539
- body.offsetHeight, documentElement.offsetHeight,
540
- body.clientHeight, documentElement.clientHeight
543
+ body.scrollHeight,
544
+ documentElement.scrollHeight,
545
+ body.offsetHeight,
546
+ documentElement.offsetHeight,
547
+ body.clientHeight,
548
+ documentElement.clientHeight
541
549
  )
542
550
  }
543
551
 
544
- getViewportHeight () {
545
- return window.innerHeight
546
- || document.documentElement.clientHeight
547
- || document.body.clientHeight
552
+ getViewportHeight() {
553
+ return (
554
+ window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
555
+ )
548
556
  }
549
557
 
550
- getElementHeight (el) {
551
- return Math.max(
552
- el.scrollHeight,
553
- el.offsetHeight,
554
- el.clientHeight
555
- )
558
+ getElementHeight(el) {
559
+ return Math.max(el.scrollHeight, el.offsetHeight, el.clientHeight)
556
560
  }
557
561
 
558
- getElementPhysicalHeight (el) {
559
- return Math.max(
560
- el.offsetHeight,
561
- el.clientHeight
562
- )
562
+ getElementPhysicalHeight(el) {
563
+ return Math.max(el.offsetHeight, el.clientHeight)
563
564
  }
564
565
 
565
- getScrollY () {
566
+ getScrollY() {
566
567
  if (this.opts.canvas.pageYOffset !== undefined) {
567
568
  return this.opts.canvas.pageYOffset
568
569
  }
@@ -572,13 +573,16 @@ export default class FixedHeader {
572
573
  return (document.documentElement || document.body.parentNode || document.body).scrollTop
573
574
  }
574
575
 
575
- toleranceExceeded () {
576
+ toleranceExceeded() {
576
577
  return Math.abs(this.currentScrollY - this.lastKnownScrollY) >= this.opts.tolerance
577
578
  }
578
579
 
579
- _getOptionsForSection (section, opts) {
580
+ _getOptionsForSection(section, opts) {
580
581
  // if section is not a key in opts, return default opts
581
- if (!Object.prototype.hasOwnProperty.call(opts, 'sections') || !Object.prototype.hasOwnProperty.call(opts.sections, section)) {
582
+ if (
583
+ !Object.prototype.hasOwnProperty.call(opts, 'sections') ||
584
+ !Object.prototype.hasOwnProperty.call(opts.sections, section)
585
+ ) {
582
586
  return opts.default
583
587
  }
584
588
 
@@ -588,17 +592,17 @@ export default class FixedHeader {
588
592
  return opts
589
593
  }
590
594
 
591
- _bindMobileMenuListeners () {
595
+ _bindMobileMenuListeners() {
592
596
  window.addEventListener('APPLICATION:MOBILE_MENU:OPEN', this._onMobileMenuOpen.bind(this))
593
597
  window.addEventListener('APPLICATION:MOBILE_MENU:CLOSED', this._onMobileMenuClose.bind(this))
594
598
  }
595
599
 
596
- _onMobileMenuOpen () {
600
+ _onMobileMenuOpen() {
597
601
  this.opts.onMobileMenuOpen(this)
598
602
  this.mobileMenuOpen = true
599
603
  }
600
604
 
601
- _onMobileMenuClose () {
605
+ _onMobileMenuClose() {
602
606
  this.opts.onMobileMenuClose(this)
603
607
  this.mobileMenuOpen = false
604
608
  }