@linear_non/stellar-kit 2.1.4 → 2.1.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linear_non/stellar-kit",
3
- "version": "2.1.4",
3
+ "version": "2.1.6",
4
4
  "description": "Stellar frontend core for Non-Linear Studio projects.",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -7,6 +7,7 @@ const DEFAULTS = {
7
7
  start: "top bottom",
8
8
  end: "bottom top",
9
9
  scrub: false,
10
+ once: true,
10
11
  markers: false,
11
12
  }
12
13
 
@@ -21,6 +22,7 @@ export default class Observer extends Emitter {
21
22
  start: this.opts.start,
22
23
  end: this.opts.end,
23
24
  scrub: this.opts.scrub,
25
+ once: this.opts.once,
24
26
  markers: this.opts.markers,
25
27
  onEnter: self => this.emit("enter", self, this),
26
28
  onLeave: self => this.emit("leave", self, this),
@@ -5,36 +5,32 @@ import { SplitText } from "../libraries/gsap"
5
5
  export const splitText = data => {
6
6
  const emitter = new Emitter()
7
7
  const splits = []
8
- let splitted = 0
9
- const totalSplits = data.length
8
+ let remaining = data.length
10
9
 
11
10
  data.forEach(el => {
12
- const dataset = el.dataset.split
13
- const data = dataset.split(",")
14
- const split = {}
11
+ const dataset = el.dataset.split || ""
12
+ const parts = dataset.split(",")
15
13
  const classes = {}
16
14
 
17
- split.el = el
18
- splitted++
19
-
20
- data.forEach((type, i) => {
21
- const filter = type.trim()
22
- if (filter == "lines") classes.linesClass = `line-${i}`
23
- if (filter == "words") classes.wordsClass = `word-${i}`
24
- if (filter == "chars") classes.charsClass = `char-${i} chr-++`
15
+ parts.forEach((type, i) => {
16
+ const t = type.trim()
17
+ if (t === "lines") classes.linesClass = `line-${i}`
18
+ if (t === "words") classes.wordsClass = `word-${i}`
19
+ if (t === "chars") classes.charsClass = `char-${i} chr-++`
25
20
  })
26
21
 
27
- const splitText = new SplitText(el, {
28
- type: dataset.toString(),
22
+ const splitInstance = new SplitText(el, {
23
+ type: dataset,
29
24
  ...classes,
30
25
  })
31
26
 
32
- splits.push(splitText)
27
+ splits.push(splitInstance)
28
+ remaining -= 1
33
29
 
34
- if (splitted == totalSplits) {
30
+ if (remaining === 0) {
35
31
  setTimeout(() => {
36
32
  emitter.emit(EVENTS.APP_SPLITTEXT_READY, splits)
37
- }, 0) // Use a small delay to ensure the event listener is set up
33
+ }, 0)
38
34
  }
39
35
  })
40
36
 
@@ -42,7 +38,5 @@ export const splitText = data => {
42
38
  }
43
39
 
44
40
  export const reverseSplit = data => {
45
- data.forEach(split => {
46
- split.revert()
47
- })
41
+ data.forEach(split => split.revert())
48
42
  }