@linear_non/stellar-kit 2.1.5 → 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.5",
3
+ "version": "2.1.6",
4
4
  "description": "Stellar frontend core for Non-Linear Studio projects.",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -5,52 +5,38 @@ 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++
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-++`
20
+ })
19
21
 
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-++`
22
+ const splitInstance = new SplitText(el, {
23
+ type: dataset,
24
+ ...classes,
25
25
  })
26
26
 
27
- document.fonts.ready
28
- .then(() => {
29
- console.log("--FONT READY--")
30
-
31
- const splitText = new SplitText(el, {
32
- type: dataset.toString(),
33
- ...classes,
34
- })
35
-
36
- splits.push(splitText)
37
-
38
- if (splitted == totalSplits) {
39
- setTimeout(() => {
40
- emitter.emit(EVENTS.APP_SPLITTEXT_READY, splits)
41
- }, 0) // Use a small delay to ensure the event listener is set up
42
- }
43
- })
44
- .catch(error => {
45
- console.error("Error loading fonts:", error)
46
- })
27
+ splits.push(splitInstance)
28
+ remaining -= 1
29
+
30
+ if (remaining === 0) {
31
+ setTimeout(() => {
32
+ emitter.emit(EVENTS.APP_SPLITTEXT_READY, splits)
33
+ }, 0)
34
+ }
47
35
  })
48
36
 
49
37
  return emitter
50
38
  }
51
39
 
52
40
  export const reverseSplit = data => {
53
- data.forEach(split => {
54
- split.revert()
55
- })
41
+ data.forEach(split => split.revert())
56
42
  }