@brandocms/jupiter 3.43.0 → 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,10 @@
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
+
1
8
  #### 3.43.0
2
9
 
3
10
  - **BREAKING** Marquee: More consistent `speed`. This means you should probably
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brandocms/jupiter",
3
- "version": "3.43.0",
3
+ "version": "3.44.0",
4
4
  "description": "Frontend helpers.",
5
5
  "author": "Univers/Twined",
6
6
  "license": "UNLICENSED",
@@ -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()
@@ -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
  }