@brandocms/jupiter 3.42.1 → 3.42.5
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/CHANGELOG.md +20 -1
- package/package.json +11 -11
- package/src/modules/Application/index.js +42 -3
- package/src/modules/HeroSlider/index.js +1 -1
- package/src/modules/Lazyload/index.js +1 -1
- package/src/modules/Links/index.js +21 -0
- package/src/modules/Moonwalk/index.js +64 -19
- package/src/modules/Popup/index.js +15 -0
- package/src/utils/zoom.js +13 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
|
+
#### 3.42.5
|
|
2
|
+
|
|
3
|
+
- Links: Fade out header/footer (if found) in default transition
|
|
4
|
+
- Moonwalk: Don't wait for images with `data-placeholder`, render right away
|
|
5
|
+
and let Lazyload do the image reveal.
|
|
6
|
+
|
|
7
|
+
#### 3.42.4
|
|
8
|
+
|
|
9
|
+
- Moonwalk: Fix fallback selector. This could have broken devices with
|
|
10
|
+
prefer reduced motion enabled.
|
|
11
|
+
|
|
12
|
+
#### 3.42.3
|
|
13
|
+
|
|
14
|
+
- Zoom: Change logic for Chrome/Safari
|
|
15
|
+
|
|
16
|
+
#### 3.42.2
|
|
17
|
+
|
|
18
|
+
- Popup: Listen for ESC to close popup
|
|
19
|
+
|
|
1
20
|
#### 3.42.1
|
|
2
21
|
|
|
3
|
-
- Moonwalk: Also remove `-children` when
|
|
22
|
+
- Moonwalk: Also remove `-children` when resetting
|
|
4
23
|
- FixedHeader: Only run `onAltBg` and `onNotAltBg` if `altBgColor` is set
|
|
5
24
|
- Application: Set browser zoom as `--ec-zoom` variable. This is used
|
|
6
25
|
in EuropaCSS for scaling/zooming vw fontsizes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brandocms/jupiter",
|
|
3
|
-
"version": "3.42.
|
|
3
|
+
"version": "3.42.5",
|
|
4
4
|
"description": "Frontend helpers.",
|
|
5
5
|
"author": "Univers/Twined",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -32,19 +32,19 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@egjs/hammerjs": "^2.0.17",
|
|
35
|
-
"body-scroll-lock": "^
|
|
36
|
-
"gsap": "3.
|
|
35
|
+
"body-scroll-lock": "^4.0.0-beta.0",
|
|
36
|
+
"gsap": "3.8.0",
|
|
37
37
|
"lodash.defaultsdeep": "^4.6.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@babel/core": "^7.
|
|
41
|
-
"@babel/preset-env": "^7.
|
|
42
|
-
"babel-jest": "^
|
|
43
|
-
"eslint": "
|
|
44
|
-
"eslint-config-airbnb-base": "^
|
|
45
|
-
"eslint-plugin-import": "^2.
|
|
40
|
+
"@babel/core": "^7.16.0",
|
|
41
|
+
"@babel/preset-env": "^7.16.4",
|
|
42
|
+
"babel-jest": "^27.3.1",
|
|
43
|
+
"eslint": "8.3.0",
|
|
44
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
45
|
+
"eslint-plugin-import": "^2.25.3",
|
|
46
46
|
"eslint-plugin-node": "^11.1.0",
|
|
47
|
-
"eslint-plugin-promise": "^5.1.
|
|
48
|
-
"jest": "^
|
|
47
|
+
"eslint-plugin-promise": "^5.1.1",
|
|
48
|
+
"jest": "^27.3.1"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -164,11 +164,51 @@ export default class Application {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
getZoom () {
|
|
167
|
-
|
|
167
|
+
switch (this.browser) {
|
|
168
|
+
case 'chrome':
|
|
169
|
+
this._lastDevicePixelRatio = Math.round(window.devicePixelRatio * 100)
|
|
170
|
+
this._initialZoom = 1
|
|
171
|
+
break
|
|
172
|
+
|
|
173
|
+
case 'safari':
|
|
174
|
+
this._zoomSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
|
|
175
|
+
this._zoomSVG.setAttribute('xmlns', 'http://www.w3.org/2000/svg')
|
|
176
|
+
this._zoomSVG.setAttribute('version', '1.1')
|
|
177
|
+
gsap.set(this._zoomSVG, { display: 'none' })
|
|
178
|
+
document.body.appendChild(this._zoomSVG)
|
|
179
|
+
this._initialZoom = this._zoomSVG.currentScale
|
|
180
|
+
break
|
|
181
|
+
|
|
182
|
+
default:
|
|
183
|
+
this._initialZoom = zoom.calculate(this.browser)
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
zoomCalculateChrome () {
|
|
188
|
+
const currentDevicePixelRatio = Math.round(window.devicePixelRatio * 100)
|
|
189
|
+
const delta = (currentDevicePixelRatio - this._lastDevicePixelRatio) / 100
|
|
190
|
+
this.size.zoom += delta
|
|
191
|
+
this._lastDevicePixelRatio = currentDevicePixelRatio
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
zoomCalculateSafari () {
|
|
195
|
+
this.size.zoom = this._zoomSVG.currentScale
|
|
168
196
|
}
|
|
169
197
|
|
|
170
198
|
updateZoom () {
|
|
171
|
-
|
|
199
|
+
switch (this.browser) {
|
|
200
|
+
case 'chrome':
|
|
201
|
+
this.zoomCalculateChrome()
|
|
202
|
+
break
|
|
203
|
+
|
|
204
|
+
case 'safari':
|
|
205
|
+
this.zoomCalculateSafari()
|
|
206
|
+
break
|
|
207
|
+
|
|
208
|
+
default:
|
|
209
|
+
this.size.zoom = 1 + (zoom.calculate(this.browser) - this._initialZoom)
|
|
210
|
+
}
|
|
211
|
+
|
|
172
212
|
this.setZoom()
|
|
173
213
|
}
|
|
174
214
|
|
|
@@ -459,7 +499,6 @@ export default class Application {
|
|
|
459
499
|
this.size.width = window.innerWidth
|
|
460
500
|
this.size.height = window.innerHeight
|
|
461
501
|
this.setvh100()
|
|
462
|
-
|
|
463
502
|
this.updateZoom()
|
|
464
503
|
|
|
465
504
|
const evt = new CustomEvent(Events.APPLICATION_RESIZE, e)
|
|
@@ -17,7 +17,10 @@ const DEFAULT_OPTIONS = {
|
|
|
17
17
|
|
|
18
18
|
onTransition: href => {
|
|
19
19
|
const main = document.querySelector('main')
|
|
20
|
+
const header = document.querySelector('header[data-nav]')
|
|
21
|
+
const footer = document.querySelector('footer')
|
|
20
22
|
const fader = document.querySelector('#fader')
|
|
23
|
+
console.log('transition')
|
|
21
24
|
|
|
22
25
|
if (fader) {
|
|
23
26
|
gsap.set(fader, { display: 'block', opacity: 0 })
|
|
@@ -26,6 +29,15 @@ const DEFAULT_OPTIONS = {
|
|
|
26
29
|
y: 25,
|
|
27
30
|
ease: 'power3.out'
|
|
28
31
|
})
|
|
32
|
+
|
|
33
|
+
if (header) {
|
|
34
|
+
gsap.to(header, { duration: 0.2, opacity: 0 })
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (footer) {
|
|
38
|
+
gsap.to(footer, { duration: 0.2, opacity: 0 })
|
|
39
|
+
}
|
|
40
|
+
|
|
29
41
|
gsap.to(fader, {
|
|
30
42
|
duration: 0.2,
|
|
31
43
|
opacity: 1,
|
|
@@ -39,6 +51,15 @@ const DEFAULT_OPTIONS = {
|
|
|
39
51
|
y: 25,
|
|
40
52
|
ease: 'power3.out'
|
|
41
53
|
})
|
|
54
|
+
|
|
55
|
+
if (header) {
|
|
56
|
+
gsap.to(header, { duration: 0.2, opacity: 0 })
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (footer) {
|
|
60
|
+
gsap.to(footer, { duration: 0.2, opacity: 0 })
|
|
61
|
+
}
|
|
62
|
+
|
|
42
63
|
gsap.to(main, {
|
|
43
64
|
duration: 0.2,
|
|
44
65
|
opacity: 0,
|
|
@@ -93,16 +93,16 @@ const DEFAULT_OPTIONS = {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
export default class Moonwalk {
|
|
96
|
-
constructor (app, opts = {}, container = document) {
|
|
96
|
+
constructor (app, opts = {}, container = document.body) {
|
|
97
97
|
this.app = app
|
|
98
98
|
this.opts = _defaultsDeep(opts, DEFAULT_OPTIONS)
|
|
99
|
-
if (container !== document) {
|
|
99
|
+
if (container !== document.body) {
|
|
100
100
|
this.opts.on = () => {}
|
|
101
101
|
}
|
|
102
102
|
this.initialize(container)
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
initialize (container = document) {
|
|
105
|
+
initialize (container = document.body) {
|
|
106
106
|
if (this.opts.clearMoonwalkOnAnchors) {
|
|
107
107
|
if (window.location.hash) {
|
|
108
108
|
this.removeAllWalks()
|
|
@@ -122,7 +122,7 @@ export default class Moonwalk {
|
|
|
122
122
|
this.clearLazyloads(container)
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
if (prefersReducedMotion()) {
|
|
125
|
+
if (prefersReducedMotion() && this.app.opts.respectReducedMotion) {
|
|
126
126
|
this.removeAllWalks(container)
|
|
127
127
|
}
|
|
128
128
|
|
|
@@ -141,14 +141,41 @@ export default class Moonwalk {
|
|
|
141
141
|
/**
|
|
142
142
|
* Remove all moonwalks. Useful for clients who prefer reduced motion
|
|
143
143
|
*/
|
|
144
|
-
removeAllWalks (container = document) {
|
|
144
|
+
removeAllWalks (container = document.body) {
|
|
145
145
|
const keys = ['data-moonwalk', 'data-moonwalk-run', 'data-moonwalk-section', 'data-moonwalk-children']
|
|
146
146
|
keys.forEach(key => {
|
|
147
147
|
const elems = container.querySelectorAll(`[${key}]`)
|
|
148
148
|
Array.from(elems).forEach(el => el.removeAttribute(key))
|
|
149
|
+
container.removeAttribute(key)
|
|
149
150
|
})
|
|
150
151
|
}
|
|
151
152
|
|
|
153
|
+
removeFor (container = document.body, selector) {
|
|
154
|
+
const keys = ['data-moonwalk', 'data-moonwalk-run', 'data-moonwalk-section', 'data-moonwalk-children']
|
|
155
|
+
keys.forEach(key => {
|
|
156
|
+
const elems = container.querySelectorAll(`${selector}[${key}]`)
|
|
157
|
+
Array.from(elems).forEach(el => el.removeAttribute(key))
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Remove run matching name
|
|
163
|
+
*/
|
|
164
|
+
removeRun (container = document.body, name) {
|
|
165
|
+
const key = 'data-moonwalk-run'
|
|
166
|
+
const elems = container.querySelectorAll(`[${key}="${name}"]`)
|
|
167
|
+
Array.from(elems).forEach(el => el.removeAttribute(key))
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Remove all runs
|
|
172
|
+
*/
|
|
173
|
+
removeRuns (container = document.body) {
|
|
174
|
+
const key = 'data-moonwalk-run'
|
|
175
|
+
const elems = container.querySelectorAll(`[${key}]`)
|
|
176
|
+
Array.from(elems).forEach(el => el.removeAttribute(key))
|
|
177
|
+
}
|
|
178
|
+
|
|
152
179
|
/**
|
|
153
180
|
* Add a random ID to each moonwalk element
|
|
154
181
|
*
|
|
@@ -180,20 +207,27 @@ export default class Moonwalk {
|
|
|
180
207
|
* Go through each `data-moonwalk-run`, parse children, add IDs/indexes
|
|
181
208
|
* (if wanted), initialize a new object for each.
|
|
182
209
|
*/
|
|
183
|
-
initializeRuns (container = document) {
|
|
210
|
+
initializeRuns (container = document.body) {
|
|
184
211
|
const runs = container.querySelectorAll('[data-moonwalk-run]')
|
|
185
|
-
return Array.from(runs).map(run =>
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
212
|
+
return Array.from(runs).map(run => {
|
|
213
|
+
const foundRun = this.opts.runs[run.getAttribute('data-moonwalk-run')]
|
|
214
|
+
if (foundRun) {
|
|
215
|
+
return {
|
|
216
|
+
el: run,
|
|
217
|
+
threshold: foundRun.threshold || 0,
|
|
218
|
+
callback: foundRun.callback
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return null
|
|
223
|
+
})
|
|
190
224
|
}
|
|
191
225
|
|
|
192
226
|
/**
|
|
193
227
|
* Go through each `data-moonwalk-section`, parse children, add IDs/indexes
|
|
194
228
|
* (if wanted), initialize a new object for each.
|
|
195
229
|
*/
|
|
196
|
-
initializeSections (container = document) {
|
|
230
|
+
initializeSections (container = document.body) {
|
|
197
231
|
const sections = container.querySelectorAll('[data-moonwalk-section]')
|
|
198
232
|
|
|
199
233
|
if (container !== document && !sections.length && container.hasAttribute('data-moonwalk-section')) {
|
|
@@ -238,7 +272,7 @@ export default class Moonwalk {
|
|
|
238
272
|
* Removes `data-moonwalk` from all elements who already have `data-ll-srcset´
|
|
239
273
|
* Can be used if Moonwalking interferes with custom lazyloading animations
|
|
240
274
|
*/
|
|
241
|
-
clearLazyloads (container = document) {
|
|
275
|
+
clearLazyloads (container = document.body) {
|
|
242
276
|
const srcsets = container.querySelectorAll('[data-ll-srcset][data-moonwalk]')
|
|
243
277
|
Array.from(srcsets).forEach(srcset => srcset.removeAttribute('data-moonwalk'))
|
|
244
278
|
}
|
|
@@ -453,6 +487,11 @@ export default class Moonwalk {
|
|
|
453
487
|
|
|
454
488
|
for (let idx = 0; idx < this.runs.length; idx += 1) {
|
|
455
489
|
const run = this.runs[idx]
|
|
490
|
+
|
|
491
|
+
if (!run) {
|
|
492
|
+
return
|
|
493
|
+
}
|
|
494
|
+
|
|
456
495
|
// if this is the last section, set rootMargin to 0
|
|
457
496
|
let rootMargin
|
|
458
497
|
|
|
@@ -578,13 +617,19 @@ export default class Moonwalk {
|
|
|
578
617
|
// ensure image is loaded before we tween
|
|
579
618
|
imageIsLoaded(entry.target).then(() => wrappedTweenFn())
|
|
580
619
|
} else {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
//
|
|
584
|
-
imagesAreLoaded(imagesInEntry).then(() => wrappedTweenFn())
|
|
585
|
-
} else {
|
|
586
|
-
// regular entry, just tween it
|
|
620
|
+
if (entry.target.hasAttribute('data-placeholder')) {
|
|
621
|
+
// if the moonwalked element has data-placeholder, we don't want to wait
|
|
622
|
+
// for the image to load before tweening
|
|
587
623
|
wrappedTweenFn()
|
|
624
|
+
} else {
|
|
625
|
+
const imagesInEntry = entry.target.querySelectorAll('img')
|
|
626
|
+
if (imagesInEntry.length) {
|
|
627
|
+
// entry has children elements that are images
|
|
628
|
+
imagesAreLoaded(imagesInEntry).then(() => wrappedTweenFn())
|
|
629
|
+
} else {
|
|
630
|
+
// regular entry, just tween it
|
|
631
|
+
wrappedTweenFn()
|
|
632
|
+
}
|
|
588
633
|
}
|
|
589
634
|
}
|
|
590
635
|
self.unobserve(entry.target)
|
|
@@ -106,6 +106,8 @@ export default class Popup {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
open (trigger, target) {
|
|
109
|
+
this.keyUpListener = this.onKeyup.bind(this)
|
|
110
|
+
document.addEventListener('keyup', this.keyUpListener)
|
|
109
111
|
if (typeof target === 'string') {
|
|
110
112
|
target = document.querySelector(target)
|
|
111
113
|
}
|
|
@@ -118,7 +120,20 @@ export default class Popup {
|
|
|
118
120
|
}
|
|
119
121
|
|
|
120
122
|
close () {
|
|
123
|
+
document.removeEventListener('keyup', this.keyUpListener)
|
|
121
124
|
this.opts.onClose(this)
|
|
122
125
|
this.opts.tweenOut(this)
|
|
123
126
|
}
|
|
127
|
+
|
|
128
|
+
onKeyup (e) {
|
|
129
|
+
const key = e.keyCode || e.which
|
|
130
|
+
|
|
131
|
+
switch (key) {
|
|
132
|
+
case 27:
|
|
133
|
+
this.close()
|
|
134
|
+
break
|
|
135
|
+
default:
|
|
136
|
+
break
|
|
137
|
+
}
|
|
138
|
+
}
|
|
124
139
|
}
|
package/src/utils/zoom.js
CHANGED
|
@@ -24,14 +24,26 @@ const _mediaQueryBinarySearch = (property, unit, a, b, maxIter, epsilon) => {
|
|
|
24
24
|
return ratio
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
Firefox: OK
|
|
29
|
+
Chrome: get the devicePixelRatio
|
|
30
|
+
|
|
31
|
+
window.devicePixelRatio - initial
|
|
32
|
+
|
|
33
|
+
*/
|
|
34
|
+
|
|
27
35
|
const calculateFirefox = () => Math.round(_mediaQueryBinarySearch('min--moz-device-pixel-ratio', '', 0, 10, 20, 0.0001) * 10) / 10
|
|
36
|
+
const calculateChrome = initial => Math.round(window.devicePixelRatio * 100) - initial
|
|
28
37
|
const calculateDefault = () => Math.round(((window.outerWidth) / window.innerWidth) * 10) / 10
|
|
29
38
|
|
|
30
39
|
const impls = {
|
|
31
40
|
firefox: calculateFirefox,
|
|
41
|
+
chrome: calculateChrome,
|
|
32
42
|
default: calculateDefault
|
|
33
43
|
}
|
|
34
44
|
|
|
35
45
|
export default {
|
|
36
|
-
calculate:
|
|
46
|
+
calculate: (browser, initial) => (
|
|
47
|
+
impls[browser] ? impls[browser](initial) : impls.default(initial)
|
|
48
|
+
)
|
|
37
49
|
}
|