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