@brandocms/jupiter 3.47.0 → 3.48.1
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.
- package/package.json +9 -9
- package/src/events/index.js +1 -0
- package/src/index.js +5 -7
- package/src/modules/Application/index.js +114 -77
- package/src/modules/Breakpoints/index.js +14 -17
- package/src/modules/Cookies/index.js +86 -43
- package/src/modules/CoverOverlay/index.js +6 -3
- package/src/modules/Dataloader/index.js +173 -7
- package/src/modules/Dom/index.js +26 -26
- package/src/modules/Dropdown/index.js +14 -14
- package/src/modules/EqualHeightElements/index.js +70 -0
- package/src/modules/EqualHeightImages/index.js +17 -18
- package/src/modules/FeatureTests/index.js +22 -15
- package/src/modules/FixedHeader/index.js +79 -75
- package/src/modules/Fontloader/index.js +5 -3
- package/src/modules/FooterReveal/index.js +1 -1
- package/src/modules/HeroSlider/index.js +33 -23
- package/src/modules/HeroVideo/index.js +15 -13
- package/src/modules/Lazyload/index.js +119 -65
- package/src/modules/Lightbox/index.js +40 -43
- package/src/modules/Links/index.js +8 -7
- package/src/modules/Marquee/index.js +40 -34
- package/src/modules/MobileMenu/index.js +112 -65
- package/src/modules/Moonwalk/index.js +256 -203
- package/src/modules/Parallax/index.js +24 -14
- package/src/modules/Popup/index.js +24 -21
- package/src/modules/ScrollSpy/index.js +5 -5
- package/src/modules/StackedBoxes/index.js +5 -5
- package/src/modules/StickyHeader/index.js +73 -70
- package/src/modules/Toggler/index.js +2 -2
- package/src/modules/Typography/index.js +13 -10
- package/src/utils/dispatchElementEvent.js +2 -2
- package/src/utils/imageIsLoaded.js +1 -1
- package/src/utils/imagesAreLoaded.js +3 -3
- package/src/utils/loadScript.js +9 -8
- package/src/utils/rafCallback.js +12 -10
- package/src/utils/zoom.js +11 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brandocms/jupiter",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.48.1",
|
|
4
4
|
"description": "Frontend helpers.",
|
|
5
5
|
"author": "Univers/Twined",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@egjs/hammerjs": "^2.0.17",
|
|
35
35
|
"body-scroll-lock": "^4.0.0-beta.0",
|
|
36
|
-
"gsap": "3.11.
|
|
36
|
+
"gsap": "3.11.3",
|
|
37
37
|
"lodash.defaultsdeep": "^4.6.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@babel/core": "^7.
|
|
41
|
-
"@babel/preset-env": "^7.
|
|
42
|
-
"babel-jest": "^29.
|
|
43
|
-
"eslint": "8.
|
|
40
|
+
"@babel/core": "^7.19.6",
|
|
41
|
+
"@babel/preset-env": "^7.19.4",
|
|
42
|
+
"babel-jest": "^29.2.1",
|
|
43
|
+
"eslint": "8.25.0",
|
|
44
44
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
45
45
|
"eslint-plugin-import": "^2.26.0",
|
|
46
46
|
"eslint-plugin-node": "^11.1.0",
|
|
47
|
-
"eslint-plugin-promise": "^6.
|
|
48
|
-
"jest": "^29.
|
|
49
|
-
"jest-environment-jsdom": "^29.
|
|
47
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
48
|
+
"jest": "^29.2.1",
|
|
49
|
+
"jest-environment-jsdom": "^29.2.1"
|
|
50
50
|
}
|
|
51
51
|
}
|
package/src/events/index.js
CHANGED
|
@@ -18,4 +18,5 @@ export const APPLICATION_VISIBLE = 'APPLICATION:VISIBLE'
|
|
|
18
18
|
export const BREAKPOINT_CHANGE = 'BREAKPOINT:CHANGE'
|
|
19
19
|
|
|
20
20
|
export const IMAGE_LAZYLOADED = 'IMAGE:LAZYLOADED'
|
|
21
|
+
export const IMAGE_REVEALED = 'IMAGE:REVEALED'
|
|
21
22
|
export const SECTION_LAZYLOADED = 'SECTION:LAZYLOADED'
|
package/src/index.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CSSPlugin,
|
|
3
|
-
Draggable,
|
|
4
|
-
ScrollToPlugin,
|
|
5
|
-
ScrollTrigger,
|
|
6
|
-
gsap
|
|
7
|
-
} from 'gsap/all'
|
|
1
|
+
import { CSSPlugin, Draggable, ScrollToPlugin, ScrollTrigger, gsap } from 'gsap/all'
|
|
8
2
|
|
|
9
3
|
import Hammer from '@egjs/hammerjs'
|
|
10
4
|
import _defaultsDeep from 'lodash.defaultsdeep'
|
|
@@ -13,8 +7,10 @@ import Application from './modules/Application'
|
|
|
13
7
|
import Breakpoints from './modules/Breakpoints'
|
|
14
8
|
import Cookies from './modules/Cookies'
|
|
15
9
|
import CoverOverlay from './modules/CoverOverlay'
|
|
10
|
+
import Dataloader from './modules/Dataloader'
|
|
16
11
|
import Dom from './modules/Dom'
|
|
17
12
|
import Dropdown from './modules/Dropdown'
|
|
13
|
+
import EqualHeightElements from './modules/EqualHeightElements'
|
|
18
14
|
import EqualHeightImages from './modules/EqualHeightImages'
|
|
19
15
|
import * as Events from './events'
|
|
20
16
|
import FixedHeader from './modules/FixedHeader'
|
|
@@ -46,9 +42,11 @@ export {
|
|
|
46
42
|
Breakpoints,
|
|
47
43
|
Cookies,
|
|
48
44
|
CoverOverlay,
|
|
45
|
+
Dataloader,
|
|
49
46
|
Dom,
|
|
50
47
|
Draggable,
|
|
51
48
|
Dropdown,
|
|
49
|
+
EqualHeightElements,
|
|
52
50
|
EqualHeightImages,
|
|
53
51
|
Events,
|
|
54
52
|
FixedHeader,
|
|
@@ -31,6 +31,10 @@ window.onpageshow = event => {
|
|
|
31
31
|
const $nav = Dom.find('header[data-nav]')
|
|
32
32
|
gsap.set($nav, { clearProps: 'opacity' })
|
|
33
33
|
|
|
34
|
+
// check that main is visible
|
|
35
|
+
const $main = Dom.find('main')
|
|
36
|
+
gsap.set($main, { clearProps: 'opacity' })
|
|
37
|
+
|
|
34
38
|
// check that footer is visible
|
|
35
39
|
const $footer = Dom.find('footer')
|
|
36
40
|
gsap.set($footer, { clearProps: 'opacity' })
|
|
@@ -44,7 +48,12 @@ const DEFAULT_OPTIONS = {
|
|
|
44
48
|
},
|
|
45
49
|
|
|
46
50
|
focusableSelectors: [
|
|
47
|
-
'a',
|
|
51
|
+
'a',
|
|
52
|
+
'input',
|
|
53
|
+
'select',
|
|
54
|
+
'button',
|
|
55
|
+
'textarea',
|
|
56
|
+
'iframe' // , 'video'?
|
|
48
57
|
],
|
|
49
58
|
|
|
50
59
|
bindScroll: true,
|
|
@@ -54,7 +63,7 @@ const DEFAULT_OPTIONS = {
|
|
|
54
63
|
disableWebpSafari: true,
|
|
55
64
|
|
|
56
65
|
faderOpts: {
|
|
57
|
-
fadeIn: (callback = () => {
|
|
66
|
+
fadeIn: (callback = () => {}) => {
|
|
58
67
|
const fader = document.querySelector('#fader')
|
|
59
68
|
gsap.to(fader, {
|
|
60
69
|
opacity: 0,
|
|
@@ -62,6 +71,9 @@ const DEFAULT_OPTIONS = {
|
|
|
62
71
|
delay: 0,
|
|
63
72
|
duration: 0.65,
|
|
64
73
|
onComplete: () => {
|
|
74
|
+
if (window.bfTO) {
|
|
75
|
+
clearTimeout(window.bfTO)
|
|
76
|
+
}
|
|
65
77
|
gsap.set(fader, { display: 'none' })
|
|
66
78
|
document.body.classList.remove('unloaded')
|
|
67
79
|
callback()
|
|
@@ -71,7 +83,7 @@ const DEFAULT_OPTIONS = {
|
|
|
71
83
|
}
|
|
72
84
|
}
|
|
73
85
|
export default class Application {
|
|
74
|
-
constructor
|
|
86
|
+
constructor(opts = {}) {
|
|
75
87
|
this.debugType = 1
|
|
76
88
|
this.debugOverlay = null
|
|
77
89
|
this.userAgent = navigator.userAgent
|
|
@@ -159,7 +171,7 @@ export default class Application {
|
|
|
159
171
|
/**
|
|
160
172
|
* Main init. Called from client application on DOMReady.
|
|
161
173
|
*/
|
|
162
|
-
initialize
|
|
174
|
+
initialize() {
|
|
163
175
|
this._emitBeforeInitializedEvent()
|
|
164
176
|
this.setSection()
|
|
165
177
|
this.executeCallbacks(Events.APPLICATION_PRELUDIUM)
|
|
@@ -170,10 +182,10 @@ export default class Application {
|
|
|
170
182
|
}
|
|
171
183
|
|
|
172
184
|
/**
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
ready
|
|
185
|
+
* Application is initialized and ready.
|
|
186
|
+
* Fade in, then execute callbacks
|
|
187
|
+
*/
|
|
188
|
+
ready() {
|
|
177
189
|
this.fontLoader.loadFonts(this.opts.fonts).then(() => {
|
|
178
190
|
this._emitReadyEvent()
|
|
179
191
|
this.executeCallbacks(Events.APPLICATION_READY)
|
|
@@ -181,7 +193,7 @@ export default class Application {
|
|
|
181
193
|
})
|
|
182
194
|
}
|
|
183
195
|
|
|
184
|
-
getZoom
|
|
196
|
+
getZoom() {
|
|
185
197
|
switch (this.browser) {
|
|
186
198
|
case 'chrome':
|
|
187
199
|
this._lastDevicePixelRatio = Math.round(window.devicePixelRatio * 100)
|
|
@@ -202,23 +214,25 @@ export default class Application {
|
|
|
202
214
|
}
|
|
203
215
|
}
|
|
204
216
|
|
|
205
|
-
zoomCalculateChrome
|
|
217
|
+
zoomCalculateChrome(dimsChanged) {
|
|
206
218
|
// only calc new zoom if width/height changed
|
|
207
219
|
if (dimsChanged) {
|
|
208
220
|
const currentDevicePixelRatio = Math.round(window.devicePixelRatio * 100)
|
|
209
221
|
const delta = (currentDevicePixelRatio - this._lastDevicePixelRatio) / 100
|
|
210
222
|
this.size.zoom += delta
|
|
211
|
-
if (this.size.zoom === 0) {
|
|
223
|
+
if (this.size.zoom === 0) {
|
|
224
|
+
this.size.zoom = 1
|
|
225
|
+
}
|
|
212
226
|
this._lastDevicePixelRatio = currentDevicePixelRatio
|
|
213
|
-
}
|
|
227
|
+
}
|
|
214
228
|
}
|
|
215
229
|
|
|
216
|
-
zoomCalculateSafari
|
|
230
|
+
zoomCalculateSafari() {
|
|
217
231
|
// safari does not call resize when switching dpi/monitors
|
|
218
232
|
this.size.zoom = this._zoomSVG.currentScale
|
|
219
233
|
}
|
|
220
234
|
|
|
221
|
-
updateZoom
|
|
235
|
+
updateZoom(dimsChanged = false, dprDelta = 0) {
|
|
222
236
|
switch (this.browser) {
|
|
223
237
|
case 'chrome':
|
|
224
238
|
this.zoomCalculateChrome(dimsChanged)
|
|
@@ -232,7 +246,9 @@ export default class Application {
|
|
|
232
246
|
if ([1, -1].indexOf(dprDelta) === -1) {
|
|
233
247
|
if (dimsChanged) {
|
|
234
248
|
this.size.zoom = 1 + (zoom.calculate(this.browser) - this._initialZoom)
|
|
235
|
-
if (this.size.zoom === 0) {
|
|
249
|
+
if (this.size.zoom === 0) {
|
|
250
|
+
this.size.zoom = 1
|
|
251
|
+
}
|
|
236
252
|
}
|
|
237
253
|
} else {
|
|
238
254
|
this._initialZoom = Math.min(Math.max(this._initialZoom - dprDelta, 1), 2)
|
|
@@ -245,14 +261,14 @@ export default class Application {
|
|
|
245
261
|
/**
|
|
246
262
|
* Fade in application, as declared in the `faderOpts`
|
|
247
263
|
*/
|
|
248
|
-
fadeIn
|
|
264
|
+
fadeIn() {
|
|
249
265
|
this.opts.faderOpts.fadeIn(this._emitRevealedEvent.bind(this))
|
|
250
266
|
}
|
|
251
267
|
|
|
252
268
|
/**
|
|
253
269
|
* Register callbacks by `type`
|
|
254
270
|
*/
|
|
255
|
-
registerCallback
|
|
271
|
+
registerCallback(type, callback) {
|
|
256
272
|
if (!Object.prototype.hasOwnProperty.call(this.callbacks, type)) {
|
|
257
273
|
this.callbacks[type] = []
|
|
258
274
|
}
|
|
@@ -262,7 +278,7 @@ export default class Application {
|
|
|
262
278
|
/**
|
|
263
279
|
* Execute callbacks by `type`
|
|
264
280
|
*/
|
|
265
|
-
executeCallbacks
|
|
281
|
+
executeCallbacks(type) {
|
|
266
282
|
if (!Object.prototype.hasOwnProperty.call(this.callbacks, type)) {
|
|
267
283
|
return
|
|
268
284
|
}
|
|
@@ -272,16 +288,19 @@ export default class Application {
|
|
|
272
288
|
/**
|
|
273
289
|
* Set section
|
|
274
290
|
*/
|
|
275
|
-
setSection
|
|
291
|
+
setSection() {
|
|
276
292
|
this.section = document.body.getAttribute('data-script')
|
|
277
293
|
}
|
|
278
294
|
|
|
279
295
|
/**
|
|
280
296
|
* Check if document is scrolled
|
|
281
297
|
*/
|
|
282
|
-
isScrolled
|
|
283
|
-
return (
|
|
284
|
-
|| document.documentElement.scrollTop) -
|
|
298
|
+
isScrolled() {
|
|
299
|
+
return (
|
|
300
|
+
(window.pageYOffset || document.documentElement.scrollTop) -
|
|
301
|
+
(document.documentElement.clientTop || 0) >
|
|
302
|
+
0
|
|
303
|
+
)
|
|
285
304
|
}
|
|
286
305
|
|
|
287
306
|
/**
|
|
@@ -289,7 +308,7 @@ export default class Application {
|
|
|
289
308
|
* `extraPaddedElements` can be a list of elements that also need padding, such as the header!
|
|
290
309
|
* @param {*} extraPaddedElements
|
|
291
310
|
*/
|
|
292
|
-
scrollLock
|
|
311
|
+
scrollLock(extraPaddedElements = []) {
|
|
293
312
|
if (this.SCROLL_LOCKED) {
|
|
294
313
|
return
|
|
295
314
|
}
|
|
@@ -303,7 +322,7 @@ export default class Application {
|
|
|
303
322
|
document.addEventListener('touchmove', this.scrollVoid, false)
|
|
304
323
|
}
|
|
305
324
|
|
|
306
|
-
scrollRelease
|
|
325
|
+
scrollRelease() {
|
|
307
326
|
if (!this.SCROLL_LOCKED) {
|
|
308
327
|
return
|
|
309
328
|
}
|
|
@@ -322,7 +341,7 @@ export default class Application {
|
|
|
322
341
|
* @param {*} time
|
|
323
342
|
* @param {*} emitEvents
|
|
324
343
|
*/
|
|
325
|
-
scrollTo
|
|
344
|
+
scrollTo(target, time = 0.8, emitEvents = true, ease = 'sine.inOut') {
|
|
326
345
|
let scrollToData
|
|
327
346
|
const forcedScrollEventStart = new window.CustomEvent(Events.APPLICATION_FORCED_SCROLL_START)
|
|
328
347
|
if (emitEvents) {
|
|
@@ -344,29 +363,29 @@ export default class Application {
|
|
|
344
363
|
window.dispatchEvent(forcedScrollEventEnd)
|
|
345
364
|
}
|
|
346
365
|
},
|
|
347
|
-
ease
|
|
366
|
+
ease
|
|
348
367
|
})
|
|
349
368
|
}
|
|
350
369
|
|
|
351
|
-
hardScrollToTop
|
|
370
|
+
hardScrollToTop() {
|
|
352
371
|
window.scrollTo(0, 0)
|
|
353
372
|
}
|
|
354
373
|
|
|
355
|
-
hardScrollTo
|
|
374
|
+
hardScrollTo(target) {
|
|
356
375
|
const element = Dom.find(target)
|
|
357
376
|
if (element) {
|
|
358
377
|
element.scrollIntoView()
|
|
359
378
|
}
|
|
360
379
|
}
|
|
361
380
|
|
|
362
|
-
scrollVoid
|
|
381
|
+
scrollVoid(e) {
|
|
363
382
|
e.preventDefault()
|
|
364
383
|
}
|
|
365
384
|
|
|
366
385
|
/**
|
|
367
386
|
* Get current scrollbar width — if there is none, there is none
|
|
368
387
|
*/
|
|
369
|
-
getCurrentScrollBarWidth
|
|
388
|
+
getCurrentScrollBarWidth() {
|
|
370
389
|
return window.innerWidth - document.documentElement.clientWidth
|
|
371
390
|
}
|
|
372
391
|
|
|
@@ -374,7 +393,7 @@ export default class Application {
|
|
|
374
393
|
* Get scrollbar width by FORCE. No matter if there is
|
|
375
394
|
* currently a scrollbar or not
|
|
376
395
|
*/
|
|
377
|
-
getScrollBarWidth
|
|
396
|
+
getScrollBarWidth() {
|
|
378
397
|
if (!this.SCROLLBAR_WIDTH) {
|
|
379
398
|
// Creating invisible container
|
|
380
399
|
const outer = document.createElement('div')
|
|
@@ -388,7 +407,7 @@ export default class Application {
|
|
|
388
407
|
outer.appendChild(inner)
|
|
389
408
|
|
|
390
409
|
// Calculating difference between container's full width and the child width
|
|
391
|
-
this.SCROLLBAR_WIDTH =
|
|
410
|
+
this.SCROLLBAR_WIDTH = outer.offsetWidth - inner.offsetWidth
|
|
392
411
|
|
|
393
412
|
// Removing temporary elements from the DOM
|
|
394
413
|
outer.parentNode.removeChild(outer)
|
|
@@ -398,7 +417,7 @@ export default class Application {
|
|
|
398
417
|
/**
|
|
399
418
|
* Ugly hacks
|
|
400
419
|
*/
|
|
401
|
-
hacks
|
|
420
|
+
hacks() {
|
|
402
421
|
if (this.opts.disableWebpSafari) {
|
|
403
422
|
if (this.browser === 'safari') {
|
|
404
423
|
console.debug('==> disable webp')
|
|
@@ -410,11 +429,11 @@ export default class Application {
|
|
|
410
429
|
}
|
|
411
430
|
}
|
|
412
431
|
|
|
413
|
-
getIOSCurrentInnerHeight
|
|
432
|
+
getIOSCurrentInnerHeight() {
|
|
414
433
|
return window.innerHeight
|
|
415
434
|
}
|
|
416
435
|
|
|
417
|
-
getIOSInnerHeightMax
|
|
436
|
+
getIOSInnerHeightMax() {
|
|
418
437
|
if (!navigator.userAgent.match(/iphone|ipod|ipad/i)) {
|
|
419
438
|
return window.innerHeight
|
|
420
439
|
}
|
|
@@ -451,21 +470,21 @@ export default class Application {
|
|
|
451
470
|
/**
|
|
452
471
|
* Event emitters
|
|
453
472
|
*/
|
|
454
|
-
_emitBeforeInitializedEvent
|
|
473
|
+
_emitBeforeInitializedEvent() {
|
|
455
474
|
window.dispatchEvent(this.beforeInitializedEvent)
|
|
456
475
|
}
|
|
457
476
|
|
|
458
|
-
_emitInitializedEvent
|
|
477
|
+
_emitInitializedEvent() {
|
|
459
478
|
window.dispatchEvent(this.initializedEvent)
|
|
460
479
|
this.INITIALIZED = true
|
|
461
480
|
}
|
|
462
481
|
|
|
463
|
-
_emitReadyEvent
|
|
482
|
+
_emitReadyEvent() {
|
|
464
483
|
window.dispatchEvent(this.readyEvent)
|
|
465
484
|
document.body.dataset.appReady = true
|
|
466
485
|
}
|
|
467
486
|
|
|
468
|
-
_emitRevealedEvent
|
|
487
|
+
_emitRevealedEvent() {
|
|
469
488
|
if (!document.body.hasAttribute('data-app-revealed')) {
|
|
470
489
|
document.body.dataset.appRevealed = true
|
|
471
490
|
window.dispatchEvent(this.revealedEvent)
|
|
@@ -473,27 +492,29 @@ export default class Application {
|
|
|
473
492
|
}
|
|
474
493
|
}
|
|
475
494
|
|
|
476
|
-
_getBaseVW
|
|
495
|
+
_getBaseVW() {
|
|
477
496
|
const fontBasePx = Dom.getCSSVar('--font-base-px')
|
|
478
497
|
const fontBase = parseFloat(fontBasePx, 10)
|
|
479
498
|
const innerWidth = window.innerWidth
|
|
480
|
-
return `${fontBase / innerWidth * 100}vw`
|
|
499
|
+
return `${(fontBase / innerWidth) * 100}vw`
|
|
481
500
|
}
|
|
482
501
|
|
|
483
|
-
setDims
|
|
502
|
+
setDims() {
|
|
484
503
|
const root = document.querySelector(':root')
|
|
485
504
|
|
|
486
505
|
this.size.initialInnerHeight = window.innerHeight
|
|
487
506
|
this.size.initialOuterHeight = window.outerHeight
|
|
488
507
|
this.size.initialInnerWidth = window.innerWidth
|
|
489
508
|
this.size.initialOuterWidth = window.outerWidth
|
|
490
|
-
|
|
509
|
+
this.size.scrollHeight = document.body.scrollHeight
|
|
510
|
+
|
|
491
511
|
root.style.setProperty('--vp-initial-inner-h', `${this.size.initialInnerHeight}px`)
|
|
492
512
|
root.style.setProperty('--vp-initial-outer-h', `${this.size.initialOuterHeight}px`)
|
|
493
513
|
root.style.setProperty('--vp-initial-inner-w', `${this.size.initialInnerWidth}px`)
|
|
494
514
|
root.style.setProperty('--vp-initial-outer-w', `${this.size.initialOuterWidth}px`)
|
|
495
515
|
root.style.setProperty('--ec-zoom', `${this.size.zoom}`)
|
|
496
|
-
|
|
516
|
+
root.style.setProperty('--scroll-h', `${this.size.scrollHeight}px`)
|
|
517
|
+
|
|
497
518
|
this.setvh100Max()
|
|
498
519
|
this.setvh100()
|
|
499
520
|
this.setFontBaseVw()
|
|
@@ -506,13 +527,13 @@ export default class Application {
|
|
|
506
527
|
this.position.left = window.pageXOffset
|
|
507
528
|
}
|
|
508
529
|
|
|
509
|
-
setFontBaseVw
|
|
530
|
+
setFontBaseVw() {
|
|
510
531
|
const root = document.querySelector(':root')
|
|
511
532
|
this.size.baseVW = this._getBaseVW()
|
|
512
533
|
root.style.setProperty('--font-base-vw', `${this.size.baseVW}`)
|
|
513
534
|
}
|
|
514
535
|
|
|
515
|
-
setZoom
|
|
536
|
+
setZoom() {
|
|
516
537
|
const root = document.querySelector(':root')
|
|
517
538
|
root.style.setProperty('--ec-zoom', `${this.size.zoom}`)
|
|
518
539
|
}
|
|
@@ -520,13 +541,13 @@ export default class Application {
|
|
|
520
541
|
/**
|
|
521
542
|
* Inner height of mobiles may change when showing hiding bottom bar.
|
|
522
543
|
*/
|
|
523
|
-
setvh100
|
|
544
|
+
setvh100() {
|
|
524
545
|
const root = document.querySelector(':root')
|
|
525
546
|
root.style.setProperty('--vp-100vh', `${window.innerHeight}px`)
|
|
526
547
|
root.style.setProperty('--vp-1vh', `${window.innerHeight * 0.01}px`)
|
|
527
548
|
}
|
|
528
549
|
|
|
529
|
-
setvw100
|
|
550
|
+
setvw100() {
|
|
530
551
|
const root = document.querySelector(':root')
|
|
531
552
|
root.style.setProperty('--vp-100vw', `${window.innerWidth}px`)
|
|
532
553
|
root.style.setProperty('--vp-1vw', `${window.innerWidth * 0.01}px`)
|
|
@@ -535,43 +556,53 @@ export default class Application {
|
|
|
535
556
|
/**
|
|
536
557
|
* Get the max 100vh for iOS
|
|
537
558
|
*/
|
|
538
|
-
setvh100Max
|
|
559
|
+
setvh100Max() {
|
|
539
560
|
const root = document.querySelector(':root')
|
|
540
561
|
const vh100 = this.featureTests.results.ios
|
|
541
|
-
? this.getIOSInnerHeightMax()
|
|
562
|
+
? this.getIOSInnerHeightMax()
|
|
563
|
+
: this.size.initialInnerHeight
|
|
542
564
|
root.style.setProperty('--vp-100vh-max', `${vh100}px`)
|
|
543
565
|
this.size.vh100max = vh100
|
|
544
566
|
}
|
|
545
567
|
|
|
546
|
-
|
|
568
|
+
setScrollHeight() {
|
|
569
|
+
const root = document.querySelector(':root')
|
|
570
|
+
root.style.setProperty('--scroll-h', `${document.body.scrollHeight}px`)
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
onBreakpointChanged() {
|
|
547
574
|
this.size.container = Dom.getCSSVar('--container-padding')
|
|
548
575
|
}
|
|
549
576
|
|
|
550
577
|
/**
|
|
551
578
|
* RAF'ed resize event
|
|
552
579
|
*/
|
|
553
|
-
onResize
|
|
554
|
-
const widthChanged =
|
|
555
|
-
const heightChanged =
|
|
580
|
+
onResize(e) {
|
|
581
|
+
const widthChanged = this.size.width !== window.innerWidth
|
|
582
|
+
const heightChanged = this.size.height !== window.innerHeight
|
|
556
583
|
const dimsChanged = widthChanged || heightChanged
|
|
557
584
|
const dprDelta = this.size.devicePixelRatio - window.devicePixelRatio
|
|
558
|
-
|
|
585
|
+
|
|
559
586
|
this.size.width = window.innerWidth
|
|
560
587
|
this.size.height = window.innerHeight
|
|
588
|
+
this.size.scrollHeight = document.body.scrollHeight
|
|
561
589
|
this.size.devicePixelRatio = window.devicePixelRatio
|
|
562
590
|
|
|
563
591
|
this.updateZoom(dimsChanged, dprDelta)
|
|
564
592
|
this.setvh100()
|
|
593
|
+
this.setScrollHeight()
|
|
565
594
|
this.setFontBaseVw()
|
|
566
595
|
|
|
567
|
-
const evt = new CustomEvent(Events.APPLICATION_RESIZE, {
|
|
596
|
+
const evt = new CustomEvent(Events.APPLICATION_RESIZE, {
|
|
597
|
+
detail: { widthChanged, heightChanged }
|
|
598
|
+
})
|
|
568
599
|
window.dispatchEvent(evt)
|
|
569
600
|
}
|
|
570
601
|
|
|
571
602
|
/**
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
onScroll
|
|
603
|
+
* RAF'ed scroll event
|
|
604
|
+
*/
|
|
605
|
+
onScroll(e) {
|
|
575
606
|
if (this.SCROLL_LOCKED) {
|
|
576
607
|
e.preventDefault()
|
|
577
608
|
return
|
|
@@ -584,7 +615,7 @@ export default class Application {
|
|
|
584
615
|
window.dispatchEvent(evt)
|
|
585
616
|
}
|
|
586
617
|
|
|
587
|
-
onVisibilityChange
|
|
618
|
+
onVisibilityChange(e) {
|
|
588
619
|
let evt = new CustomEvent(Events.APPLICATION_VISIBILITY_CHANGE, e)
|
|
589
620
|
window.dispatchEvent(evt)
|
|
590
621
|
|
|
@@ -597,7 +628,7 @@ export default class Application {
|
|
|
597
628
|
}
|
|
598
629
|
}
|
|
599
630
|
|
|
600
|
-
pollForElement
|
|
631
|
+
pollForElement(selector, time = 500, callback = () => {}) {
|
|
601
632
|
const el = document.querySelector(selector)
|
|
602
633
|
if (el !== null) {
|
|
603
634
|
callback(el)
|
|
@@ -608,7 +639,7 @@ export default class Application {
|
|
|
608
639
|
}
|
|
609
640
|
}
|
|
610
641
|
|
|
611
|
-
pollForVar
|
|
642
|
+
pollForVar(variable, time = 500, callback = () => {}) {
|
|
612
643
|
if (variable !== null) {
|
|
613
644
|
callback(variable)
|
|
614
645
|
} else {
|
|
@@ -618,7 +649,7 @@ export default class Application {
|
|
|
618
649
|
}
|
|
619
650
|
}
|
|
620
651
|
|
|
621
|
-
setupDebug
|
|
652
|
+
setupDebug() {
|
|
622
653
|
this.setupGridoverlay()
|
|
623
654
|
this.debugOverlay = document.querySelector('.dbg-breakpoints')
|
|
624
655
|
if (!this.debugOverlay) {
|
|
@@ -631,10 +662,10 @@ export default class Application {
|
|
|
631
662
|
userAgent.innerHTML = `<b>→ ${this.userAgent}</b> >> <span>KOPIER</span>`
|
|
632
663
|
|
|
633
664
|
const span = userAgent.querySelector('span')
|
|
634
|
-
const windowWidth =
|
|
635
|
-
|| document.body.clientWidth
|
|
636
|
-
const windowHeight =
|
|
637
|
-
|| document.body.clientHeight
|
|
665
|
+
const windowWidth =
|
|
666
|
+
window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
|
|
667
|
+
const windowHeight =
|
|
668
|
+
window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
|
|
638
669
|
|
|
639
670
|
span.addEventListener('click', () => {
|
|
640
671
|
const copyText = userAgent.querySelector('b')
|
|
@@ -658,7 +689,7 @@ ${JSON.stringify(this.featureTests.results, undefined, 2)}
|
|
|
658
689
|
})
|
|
659
690
|
}
|
|
660
691
|
|
|
661
|
-
toggleDebug
|
|
692
|
+
toggleDebug() {
|
|
662
693
|
const tl = gsap.timeline()
|
|
663
694
|
const breakpoint = this.debugOverlay.querySelector('.breakpoint')
|
|
664
695
|
const userAgent = this.debugOverlay.querySelector('.user-agent')
|
|
@@ -674,21 +705,27 @@ ${JSON.stringify(this.featureTests.results, undefined, 2)}
|
|
|
674
705
|
// hide all except branding
|
|
675
706
|
tl.to([breakpoint, userAgent], { duration: 0.3, autoAlpha: 0 })
|
|
676
707
|
.to([breakpoint, userAgent], { duration: 0.7, width: 0 })
|
|
677
|
-
.call(() => {
|
|
708
|
+
.call(() => {
|
|
709
|
+
gsap.set([breakpoint, userAgent], { display: 'none' })
|
|
710
|
+
})
|
|
678
711
|
break
|
|
679
712
|
|
|
680
713
|
case 1:
|
|
681
714
|
//
|
|
682
715
|
gsap.set(breakpoint, { width: 'auto', display: 'block' })
|
|
683
|
-
tl.from(breakpoint, { duration: 0.7, width: 0 })
|
|
684
|
-
|
|
716
|
+
tl.from(breakpoint, { duration: 0.7, width: 0 }).to(breakpoint, {
|
|
717
|
+
duration: 0.3,
|
|
718
|
+
autoAlpha: 1
|
|
719
|
+
})
|
|
685
720
|
break
|
|
686
721
|
|
|
687
722
|
case 2:
|
|
688
723
|
//
|
|
689
724
|
gsap.set(userAgent, { width: 'auto', display: 'block' })
|
|
690
|
-
tl.from(userAgent, { duration: 0.7, width: 0 })
|
|
691
|
-
|
|
725
|
+
tl.from(userAgent, { duration: 0.7, width: 0 }).to(userAgent, {
|
|
726
|
+
duration: 0.3,
|
|
727
|
+
autoAlpha: 1
|
|
728
|
+
})
|
|
692
729
|
break
|
|
693
730
|
|
|
694
731
|
default:
|
|
@@ -699,7 +736,7 @@ ${JSON.stringify(this.featureTests.results, undefined, 2)}
|
|
|
699
736
|
/**
|
|
700
737
|
* CTRL-G to show grid overlay
|
|
701
738
|
*/
|
|
702
|
-
setupGridoverlay
|
|
739
|
+
setupGridoverlay() {
|
|
703
740
|
const gridKeyPressed = e => {
|
|
704
741
|
if (e.keyCode === 71 && e.ctrlKey) {
|
|
705
742
|
const guides = Dom.find('.dbg-grid')
|
|
@@ -739,7 +776,7 @@ ${JSON.stringify(this.featureTests.results, undefined, 2)}
|
|
|
739
776
|
* Add in extra selectors that are focusable
|
|
740
777
|
* @param {array} extraSelectors
|
|
741
778
|
*/
|
|
742
|
-
addFocusableSelectors
|
|
779
|
+
addFocusableSelectors(extraSelectors) {
|
|
743
780
|
if (extraSelectors.length) {
|
|
744
781
|
this.focusableSelectors = this.focusableSelectors.concat(extraSelectors)
|
|
745
782
|
}
|
|
@@ -749,7 +786,7 @@ ${JSON.stringify(this.featureTests.results, undefined, 2)}
|
|
|
749
786
|
* Set focusable selectors. Replaces default array.
|
|
750
787
|
* @param {array} selectors
|
|
751
788
|
*/
|
|
752
|
-
setFocusableSelectors
|
|
789
|
+
setFocusableSelectors(selectors) {
|
|
753
790
|
if (selectors.length) {
|
|
754
791
|
this.focusableSelectors = selectors
|
|
755
792
|
}
|
|
@@ -758,7 +795,7 @@ ${JSON.stringify(this.featureTests.results, undefined, 2)}
|
|
|
758
795
|
/**
|
|
759
796
|
* Returns focusable selectors as a comma separated list
|
|
760
797
|
*/
|
|
761
|
-
getFocusableSelectors
|
|
798
|
+
getFocusableSelectors() {
|
|
762
799
|
return this.focusableSelectors.join(',')
|
|
763
800
|
}
|
|
764
801
|
}
|