@brandocms/jupiter 3.45.0 → 3.46.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/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ #### 3.46.0
2
+
3
+ - **BREAKING** Marquee: Drop `paddingLeft` -- add `startProgress`. This sets where in the
4
+ timeline we should start. Default is `0.5`
5
+ - Application: Add `hardScrollToTop()`
6
+ - Zoom: Try to improve zoom handling for chrome
7
+
8
+
1
9
  #### 3.45.0
2
10
 
3
11
  - Marquee: Reveal on `APPLICATION:REVEALED`
package/README.md CHANGED
@@ -268,7 +268,7 @@ include images from this section. Otherwise, all lightboxed images will be inclu
268
268
  HTML
269
269
  ```html
270
270
  <div data-toggle>
271
- <button data-toggle-trigger>Click to expand <span class="arrow">&darr;</span></button>
271
+ <button data-toggle-trigger>Click to expand <span class="arrow icon">&darr;</span></button>
272
272
  <div class="panel" data-toggle-content>
273
273
  <div class="panel-content">
274
274
  Content goes here
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brandocms/jupiter",
3
- "version": "3.45.0",
3
+ "version": "3.46.0",
4
4
  "description": "Frontend helpers.",
5
5
  "author": "Univers/Twined",
6
6
  "license": "UNLICENSED",
@@ -71,6 +71,7 @@ export default class Application {
71
71
  this.userAgent = navigator.userAgent
72
72
  this._lastWindowHeight = 0
73
73
  this.breakpoint = null
74
+ this.language = document.documentElement.lang
74
75
 
75
76
  this.size = {
76
77
  width: 0,
@@ -195,29 +196,41 @@ export default class Application {
195
196
  }
196
197
  }
197
198
 
198
- zoomCalculateChrome () {
199
- const currentDevicePixelRatio = Math.round(window.devicePixelRatio * 100)
200
- const delta = (currentDevicePixelRatio - this._lastDevicePixelRatio) / 100
201
- this.size.zoom += delta
202
- this._lastDevicePixelRatio = currentDevicePixelRatio
199
+ zoomCalculateChrome (dimsChanged) {
200
+ // only calc new zoom if width/height changed
201
+ if (dimsChanged) {
202
+ const currentDevicePixelRatio = Math.round(window.devicePixelRatio * 100)
203
+ const delta = (currentDevicePixelRatio - this._lastDevicePixelRatio) / 100
204
+ this.size.zoom += delta
205
+ if (this.size.zoom === 0) { this.size.zoom = 1 }
206
+ this._lastDevicePixelRatio = currentDevicePixelRatio
207
+ }
203
208
  }
204
209
 
205
210
  zoomCalculateSafari () {
211
+ // safari does not call resize when switching dpi/monitors
206
212
  this.size.zoom = this._zoomSVG.currentScale
207
213
  }
208
214
 
209
- updateZoom () {
215
+ updateZoom (dimsChanged = false, dprDelta = 0) {
210
216
  switch (this.browser) {
211
217
  case 'chrome':
212
- this.zoomCalculateChrome()
218
+ this.zoomCalculateChrome(dimsChanged)
213
219
  break
214
220
 
215
221
  case 'safari':
216
- this.zoomCalculateSafari()
222
+ this.zoomCalculateSafari(dimsChanged)
217
223
  break
218
224
 
219
225
  default:
220
- this.size.zoom = 1 + (zoom.calculate(this.browser) - this._initialZoom)
226
+ if ([1, -1].indexOf(dprDelta) === -1) {
227
+ if (dimsChanged) {
228
+ this.size.zoom = 1 + (zoom.calculate(this.browser) - this._initialZoom)
229
+ if (this.size.zoom === 0) { this.size.zoom = 1 }
230
+ }
231
+ } else {
232
+ this._initialZoom = Math.min(Math.max(this._initialZoom - dprDelta, 1), 2)
233
+ }
221
234
  }
222
235
 
223
236
  this.setZoom()
@@ -329,6 +342,10 @@ export default class Application {
329
342
  })
330
343
  }
331
344
 
345
+ hardScrollToTop () {
346
+ window.scrollTo(0, 0)
347
+ }
348
+
332
349
  hardScrollTo (target) {
333
350
  const element = Dom.find(target)
334
351
  if (element) {
@@ -450,6 +467,13 @@ export default class Application {
450
467
  }
451
468
  }
452
469
 
470
+ _getBaseVW () {
471
+ const fontBasePx = Dom.getCSSVar('--font-base-px')
472
+ const fontBase = parseFloat(fontBasePx, 10)
473
+ const innerWidth = window.innerWidth
474
+ return `${fontBase / innerWidth * 100}vw`
475
+ }
476
+
453
477
  setDims () {
454
478
  const root = document.querySelector(':root')
455
479
 
@@ -457,16 +481,18 @@ export default class Application {
457
481
  this.size.initialOuterHeight = window.outerHeight
458
482
  this.size.initialInnerWidth = window.innerWidth
459
483
  this.size.initialOuterWidth = window.outerWidth
460
-
484
+
461
485
  root.style.setProperty('--vp-initial-inner-h', `${this.size.initialInnerHeight}px`)
462
486
  root.style.setProperty('--vp-initial-outer-h', `${this.size.initialOuterHeight}px`)
463
487
  root.style.setProperty('--vp-initial-inner-w', `${this.size.initialInnerWidth}px`)
464
488
  root.style.setProperty('--vp-initial-outer-w', `${this.size.initialOuterWidth}px`)
465
489
  root.style.setProperty('--ec-zoom', `${this.size.zoom}`)
466
-
490
+
467
491
  this.setvh100Max()
468
492
  this.setvh100()
493
+ this.setFontBaseVw()
469
494
 
495
+ this.size.devicePixelRatio = window.devicePixelRatio
470
496
  this.size.container = Dom.getCSSVar('--container-padding')
471
497
  this.size.width = window.innerWidth
472
498
  this.size.height = window.innerHeight
@@ -474,6 +500,12 @@ export default class Application {
474
500
  this.position.left = window.pageXOffset
475
501
  }
476
502
 
503
+ setFontBaseVw () {
504
+ const root = document.querySelector(':root')
505
+ this.size.baseVW = this._getBaseVW()
506
+ root.style.setProperty('--font-base-vw', `${this.size.baseVW}`)
507
+ }
508
+
477
509
  setZoom () {
478
510
  const root = document.querySelector(':root')
479
511
  root.style.setProperty('--ec-zoom', `${this.size.zoom}`)
@@ -488,6 +520,12 @@ export default class Application {
488
520
  root.style.setProperty('--vp-1vh', `${window.innerHeight * 0.01}px`)
489
521
  }
490
522
 
523
+ setvw100 () {
524
+ const root = document.querySelector(':root')
525
+ root.style.setProperty('--vp-100vw', `${window.innerWidth}px`)
526
+ root.style.setProperty('--vp-1vw', `${window.innerWidth * 0.01}px`)
527
+ }
528
+
491
529
  /**
492
530
  * Get the max 100vh for iOS
493
531
  */
@@ -509,11 +547,16 @@ export default class Application {
509
547
  onResize (e) {
510
548
  const widthChanged = (this.size.width !== window.innerWidth)
511
549
  const heightChanged = (this.size.height !== window.innerHeight)
512
-
550
+ const dimsChanged = widthChanged || heightChanged
551
+ const dprDelta = this.size.devicePixelRatio - window.devicePixelRatio
552
+
513
553
  this.size.width = window.innerWidth
514
554
  this.size.height = window.innerHeight
555
+ this.size.devicePixelRatio = window.devicePixelRatio
556
+
557
+ this.updateZoom(dimsChanged, dprDelta)
515
558
  this.setvh100()
516
- this.updateZoom()
559
+ this.setFontBaseVw()
517
560
 
518
561
  const evt = new CustomEvent(Events.APPLICATION_RESIZE, { detail: { widthChanged, heightChanged } })
519
562
  window.dispatchEvent(evt)
@@ -0,0 +1,8 @@
1
+ /**
2
+ * <article
3
+ * data-loader>
4
+ * <div data-loader-canvas>
5
+ *
6
+ * </div>
7
+ *
8
+ */
@@ -191,6 +191,14 @@ export default class Lazyload {
191
191
  img.removeAttribute('data-ll-blurred')
192
192
  img.removeAttribute('data-ll-loading')
193
193
  img.setAttribute('data-ll-loaded', '')
194
+
195
+ // set sizes attribute on load again, since firefox sometimes is a bit slow to
196
+ // get the actual image width
197
+ const width = this.getWidth(img)
198
+ img.setAttribute('sizes', `${width}px`)
199
+ if (img.parentNode) {
200
+ Array.from(Dom.all(img.parentNode, 'source')).forEach(source => source.setAttribute('sizes', `${width}px`))
201
+ }
194
202
  }
195
203
 
196
204
  img.addEventListener('load', onload, false)
@@ -15,7 +15,7 @@ const DEFAULT_OPTIONS = {
15
15
  links.app.scrollTo(target, links.opts.scrollDuration, links.opts.triggerEvents)
16
16
  },
17
17
 
18
- onTransition: href => {
18
+ onTransition: (href, app) => {
19
19
  const main = document.querySelector('main')
20
20
  const header = document.querySelector('header[data-nav]')
21
21
  const footer = document.querySelector('footer')
@@ -152,7 +152,7 @@ export default class Links {
152
152
 
153
153
  if (href.indexOf(document.location.hostname) > -1 || href.startsWith('/')) {
154
154
  e.preventDefault()
155
- this.opts.onTransition(href)
155
+ this.opts.onTransition(href, this.app)
156
156
  }
157
157
  })
158
158
  })
@@ -6,7 +6,9 @@ const DEFAULT_OPTIONS = {
6
6
  speed: 100,
7
7
  extraHeight: 0,
8
8
  slowDownOnHover: true,
9
- paddingLeft: 0,
9
+ paddingLeft: 0, //DEPRECATED
10
+ startProgress: 0,
11
+
10
12
  onReveal: marqueeEl => {
11
13
  gsap.to(marqueeEl, { opacity: 1 })
12
14
  }
@@ -87,14 +89,16 @@ export default class Marquee {
87
89
  const $allHolders = Dom.all(this.elements.$el, '[data-marquee-holder]')
88
90
 
89
91
  Array.from($allHolders).forEach((h, idx) => {
90
- gsap.set(h, { position: 'absolute', left: h.offsetWidth * idx })
92
+ gsap.set(h, { position: 'absolute', left: (h.offsetWidth * idx) })
91
93
  })
92
94
 
93
95
  this.timeline = gsap.timeline({ paused: true })
94
96
  this.timeline
95
- .to($allHolders, { xPercent: -100, ease: 'none', duration: this.duration })
97
+ .to($allHolders, { xPercent: -100, ease: 'none', duration: this.duration }, 'standard')
96
98
  .repeat(-1)
97
99
 
100
+ this.timeline.totalProgress(this.opts.startProgress)
101
+
98
102
  window.timeline = this.timeline
99
103
  window.marquee = this
100
104
  }
@@ -172,7 +176,7 @@ export default class Marquee {
172
176
 
173
177
  const textWidth = this.elements.$item.offsetWidth
174
178
  if (textWidth) {
175
- const count = Math.ceil(this.app.size.width / textWidth) - 1
179
+ const count = Math.max(Math.ceil(this.app.size.width / textWidth) - 1, 2)
176
180
 
177
181
  for (let i = 0; i < count; i += 1) {
178
182
  this.elements.$holder.append(this.elements.$item.cloneNode(true))
@@ -576,7 +576,7 @@ export default class Moonwalk {
576
576
  } = cfg
577
577
 
578
578
  let { alphaTween } = cfg
579
- let overlap = duration - interval
579
+ let overlap = (duration - interval) * -1 // flip it
580
580
 
581
581
  if (section.stage.firstTween) {
582
582
  overlap = 0
@@ -599,6 +599,7 @@ export default class Moonwalk {
599
599
  section,
600
600
  entry.target,
601
601
  duration,
602
+ interval,
602
603
  transition,
603
604
  overlap,
604
605
  alphaTween
@@ -651,7 +652,7 @@ export default class Moonwalk {
651
652
  * @param {*} tweenOverlap
652
653
  * @param {*} alphaTween
653
654
  */
654
- tweenJS (section, target, tweenDuration, tweenTransition, tweenOverlap, alphaTween) {
655
+ tweenJS (section, target, tweenDuration, tweenInterval, tweenTransition, tweenOverlap, alphaTween) {
655
656
  let tweenPosition
656
657
  const startingPoint = tweenDuration - tweenOverlap
657
658
 
@@ -666,10 +667,10 @@ export default class Moonwalk {
666
667
  tweenPosition = () => section.timeline.time()
667
668
  } else {
668
669
  /* Still time, add as normal overlap at the end */
669
- tweenPosition = () => `>-${tweenOverlap}`
670
+ tweenPosition = () => `>${tweenOverlap}`
670
671
  }
671
672
  } else {
672
- tweenPosition = () => '+=0'
673
+ tweenPosition = () => '>'
673
674
  }
674
675
 
675
676
  gsap.set(target, tweenTransition.from)
@@ -702,10 +703,10 @@ export default class Moonwalk {
702
703
  * @param {*} transition
703
704
  * @param {*} overlap
704
705
  */
705
- tweenCSS (section, target, tweenDuration, tweenTransition, tweenOverlap) {
706
+ tweenCSS (section, target, tweenDuration, tweenInterval, tweenTransition, tweenOverlap) {
706
707
  let tweenPosition
707
- const startingPoint = tweenDuration - tweenOverlap
708
-
708
+ const startingPoint = tweenDuration - (tweenOverlap * -1)
709
+
709
710
  if (Dom.hasAttribute(target, 'data-moonwalked')) {
710
711
  return
711
712
  }
@@ -717,10 +718,10 @@ export default class Moonwalk {
717
718
  tweenPosition = () => section.timeline.time()
718
719
  } else {
719
720
  /* Still time, add as normal overlap at the end */
720
- tweenPosition = () => `>-${tweenOverlap}`
721
+ tweenPosition = () => `>${tweenOverlap}`
721
722
  }
722
723
  } else {
723
- tweenPosition = () => '+=0'
724
+ tweenPosition = () => '>'
724
725
  }
725
726
 
726
727
  section.timeline.to(
@@ -731,6 +732,6 @@ export default class Moonwalk {
731
732
  duration: tweenDuration
732
733
  },
733
734
  tweenPosition()
734
- ).call(() => { target.setAttribute('data-moonwalked', '') }, null, '<')
735
+ ).call(() => target.setAttribute('data-moonwalked', ''), null, '>')
735
736
  }
736
737
  }
@@ -18,6 +18,12 @@ export default class Typography {
18
18
  self.elems = [...parent.querySelectorAll(self.settings.selector)]
19
19
  }
20
20
 
21
+ // load children
22
+ const typoParents = document.querySelectorAll('[data-typo-children]')
23
+ typoParents.forEach(typoParent => {
24
+ self.elems = [...typoParent.children]
25
+ })
26
+
21
27
  this.apply()
22
28
  }
23
29
 
package/src/utils/zoom.js CHANGED
@@ -24,15 +24,10 @@ 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
- */
27
+ const calculateFirefox = () => {
28
+ return Math.round(_mediaQueryBinarySearch('min--moz-device-pixel-ratio', '', 0, 10, 20, 0.0001) * 10) / 10
29
+ }
34
30
 
35
- const calculateFirefox = () => Math.round(_mediaQueryBinarySearch('min--moz-device-pixel-ratio', '', 0, 10, 20, 0.0001) * 10) / 10
36
31
  const calculateChrome = initial => Math.round(window.devicePixelRatio * 100) - initial
37
32
  const calculateDefault = () => Math.round(((window.outerWidth) / window.innerWidth) * 10) / 10
38
33