@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 +1 -1
- package/plugins/SplitText.js +21 -35
package/package.json
CHANGED
package/plugins/SplitText.js
CHANGED
|
@@ -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
|
|
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
|
|
14
|
-
const split = {}
|
|
11
|
+
const dataset = el.dataset.split || ""
|
|
12
|
+
const parts = dataset.split(",")
|
|
15
13
|
const classes = {}
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
}
|