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