@brandocms/jupiter 3.42.6 → 3.44.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,24 @@
1
+ #### 3.44.0
2
+
3
+ - Moonwalk: Add `data-moonwalked` to walked elements. Don't run again on
4
+ already walked elements.
5
+ - Dom: Add `hasAttribute`
6
+
7
+
8
+ #### 3.43.0
9
+
10
+ - **BREAKING** Marquee: More consistent `speed`. This means you should probably
11
+ verify that the speed you set looks ok with the new config
12
+ - Marquee: Add `paddingLeft` and `slowDownOnHover` options
13
+ - Application: send `widthChanged` and `heightChanged` booleans
14
+ in `APPLICATION:RESIZE` event detail
15
+
16
+
17
+ #### 3.42.7
18
+
19
+ - Links: Check for zero opacity body element on back/forward nav
20
+
21
+
1
22
  #### 3.42.6
2
23
 
3
24
  - Typography: Better defaults
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brandocms/jupiter",
3
- "version": "3.42.6",
3
+ "version": "3.44.0",
4
4
  "description": "Frontend helpers.",
5
5
  "author": "Univers/Twined",
6
6
  "license": "UNLICENSED",
@@ -15,8 +15,19 @@ gsap.defaults({ overwrite: 'auto', ease: 'sine.out' })
15
15
 
16
16
  window.onpageshow = event => {
17
17
  if (event.persisted) {
18
- gsap.to(document.querySelector('#fader'), { duration: 0.35, autoAlpha: 0 })
19
- gsap.to(document.querySelectorAll('[data-fader]'), { duration: 0.35, autoAlpha: 0 })
18
+ const f = document.querySelector('#fader')
19
+ if (f) {
20
+ gsap.to(f, { duration: 0.35, autoAlpha: 0 })
21
+ }
22
+
23
+ const dataFaders = document.querySelectorAll('[data-fader]')
24
+ if (dataFaders.length) {
25
+ gsap.to(dataFaders, { duration: 0.35, autoAlpha: 0 })
26
+ }
27
+
28
+ gsap.set(document.body, {
29
+ clearProps: 'opacity'
30
+ })
20
31
  }
21
32
  }
22
33
 
@@ -496,12 +507,15 @@ export default class Application {
496
507
  * RAF'ed resize event
497
508
  */
498
509
  onResize (e) {
510
+ const widthChanged = (this.size.width !== window.innerWidth)
511
+ const heightChanged = (this.size.height !== window.innerHeight)
512
+
499
513
  this.size.width = window.innerWidth
500
514
  this.size.height = window.innerHeight
501
515
  this.setvh100()
502
516
  this.updateZoom()
503
517
 
504
- const evt = new CustomEvent(Events.APPLICATION_RESIZE, e)
518
+ const evt = new CustomEvent(Events.APPLICATION_RESIZE, { detail: { widthChanged, heightChanged } })
505
519
  window.dispatchEvent(evt)
506
520
  }
507
521
 
@@ -73,6 +73,10 @@ class DOM {
73
73
  return classes.map(className => element.classList.toggle(className))
74
74
  }
75
75
 
76
+ hasAttribute (element, attributeName) {
77
+ return element.hasAttribute(attributeName)
78
+ }
79
+
76
80
  overlapsVertically ($div1, $div2) {
77
81
  // Div 1 data
78
82
  const d1Offset = $div1.getBoundingClientRect()
@@ -3,8 +3,10 @@ import _defaultsDeep from 'lodash.defaultsdeep'
3
3
  import Dom from '../Dom'
4
4
 
5
5
  const DEFAULT_OPTIONS = {
6
- speed: 25,
7
- extraHeight: 0
6
+ speed: 100,
7
+ extraHeight: 0,
8
+ slowDownOnHover: true,
9
+ paddingLeft: 0
8
10
  }
9
11
 
10
12
  export default class Marquee {
@@ -26,18 +28,29 @@ export default class Marquee {
26
28
  window.addEventListener('APPLICATION:RESIZE', this.updateMarquee.bind(this))
27
29
  this.updateMarquee()
28
30
  this.setupObserver()
29
- this.elements.$el.addEventListener('mouseenter', this.slowDown.bind(this))
30
- this.elements.$el.addEventListener('mouseleave', this.speedUp.bind(this))
31
+ if (this.opts.slowDownOnHover) {
32
+ this.elements.$el.addEventListener('mouseenter', this.slowDown.bind(this))
33
+ this.elements.$el.addEventListener('mouseleave', this.speedUp.bind(this))
34
+ }
31
35
  }
32
36
 
33
- updateMarquee () {
37
+ updateMarquee (e) {
38
+ if (e) {
39
+ // updating cause of a resize. we only care about width change
40
+ if (!e.detail.widthChanged) {
41
+ return
42
+ }
43
+ }
34
44
  this.killTweens()
35
45
  this.clearHolders()
36
46
  this.setHeight()
37
47
  this.fillText()
48
+
38
49
  const holderWidth = this.elements.$holder.offsetWidth
39
50
  const $allHolders = Dom.all(this.elements.$el, '[data-marquee-holder]')
40
51
  const marqueeWidth = holderWidth * $allHolders.length
52
+
53
+ this.duration = holderWidth / this.opts.speed
41
54
 
42
55
  gsap.set(this.elements.$marquee, { width: marqueeWidth })
43
56
  this.initializeTween()
@@ -68,7 +81,7 @@ export default class Marquee {
68
81
 
69
82
  this.timeline = gsap.timeline({ paused: true })
70
83
  this.timeline
71
- .to($allHolders, this.opts.speed, { xPercent: -100, ease: 'none' })
84
+ .to($allHolders, { xPercent: -100, ease: 'none', duration: this.duration })
72
85
  .repeat(-1)
73
86
 
74
87
  window.timeline = this.timeline
@@ -655,6 +655,10 @@ export default class Moonwalk {
655
655
  let tweenPosition
656
656
  const startingPoint = tweenDuration - tweenOverlap
657
657
 
658
+ if (Dom.hasAttribute(target, 'data-moonwalked')) {
659
+ return
660
+ }
661
+
658
662
  if (section.timeline.isActive() && section.timeline.recent()) {
659
663
  if (section.timeline.recent().time() > startingPoint) {
660
664
  /* We're late for this tween if it was supposed to be sequential,
@@ -677,6 +681,7 @@ export default class Moonwalk {
677
681
  },
678
682
  tweenPosition()
679
683
  )
684
+ .call(() => { target.setAttribute('data-moonwalked', '') }, null, '<')
680
685
 
681
686
  if (alphaTween) {
682
687
  section.timeline.to(target, {
@@ -701,7 +706,7 @@ export default class Moonwalk {
701
706
  let tweenPosition
702
707
  const startingPoint = tweenDuration - tweenOverlap
703
708
 
704
- if (Dom.hasClass(target, 'moonwalked')) {
709
+ if (Dom.hasAttribute(target, 'data-moonwalked')) {
705
710
  return
706
711
  }
707
712
 
@@ -726,6 +731,6 @@ export default class Moonwalk {
726
731
  duration: tweenDuration
727
732
  },
728
733
  tweenPosition()
729
- )
734
+ ).call(() => { target.setAttribute('data-moonwalked', '') }, null, '<')
730
735
  }
731
736
  }