@linear_non/stellar-kit 1.0.9 → 1.0.11

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/events/Emitter.js CHANGED
@@ -63,5 +63,5 @@ const PRIORITY = {
63
63
  low: 30,
64
64
  }
65
65
 
66
- export { EVENTS, PRIORITY }
66
+ export { Emitter, EVENTS, PRIORITY }
67
67
  export default emitter
package/events/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import emitter, { EVENTS, PRIORITY } from "./Emitter"
1
+ import emitter, { Emitter, EVENTS, PRIORITY } from "./Emitter"
2
2
  import VirtualScroll from "./VirtualScroll"
3
3
  import Scroll from "./Scroll"
4
4
  import Resize from "./Resize"
5
5
  import Mouse from "./Mouse"
6
6
  import Raf from "./Raf"
7
7
 
8
- export { emitter, EVENTS, PRIORITY, Resize, VirtualScroll, Scroll, Mouse, Raf }
8
+ export { emitter, Emitter, EVENTS, PRIORITY, Resize, VirtualScroll, Scroll, Mouse, Raf }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linear_non/stellar-kit",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Stellar frontend core for Non-Linear Studio projects.",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -1,45 +1,48 @@
1
1
  // splitText.js
2
- import { emitter, EVENTS } from "../events"
2
+ import { Emitter, EVENTS } from "../events"
3
3
  import { SplitText } from "../libraries/gsap"
4
4
 
5
- // Emits `APP_SPLITTEXT_READY` once all elements are split
6
- export const splitText = elements => {
5
+ export const splitText = data => {
6
+ const emitter = new Emitter()
7
7
  const splits = []
8
8
  let splitted = 0
9
- const totalSplits = elements.length
9
+ const totalSplits = data.length
10
10
 
11
- elements.forEach(el => {
11
+ data.forEach(el => {
12
12
  const dataset = el.dataset.split
13
- const types = dataset.split(",")
13
+ const data = dataset.split(",")
14
+ const split = {}
14
15
  const classes = {}
15
16
 
16
- types.forEach((type, i) => {
17
- const t = type.trim()
18
- if (t === "lines") classes.linesClass = `line-${i}`
19
- if (t === "words") classes.wordsClass = `word-${i}`
20
- if (t === "chars") classes.charsClass = `char-${i} chr-++`
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-++`
21
25
  })
22
26
 
23
- const splitInstance = new SplitText(el, {
27
+ const splitText = new SplitText(el, {
24
28
  type: dataset.toString(),
25
29
  ...classes,
26
30
  })
27
31
 
28
- splits.push(splitInstance)
29
- splitted++
32
+ splits.push(splitText)
30
33
 
31
- if (splitted === totalSplits) {
34
+ if (splitted == totalSplits) {
32
35
  setTimeout(() => {
33
36
  emitter.emit(EVENTS.APP_SPLITTEXT_READY, splits)
34
- }, 0)
37
+ }, 0) // Use a small delay to ensure the event listener is set up
35
38
  }
36
39
  })
37
40
 
38
- return splits
41
+ return emitter
39
42
  }
40
43
 
41
- export const reverseSplit = instances => {
42
- instances.forEach(split => {
44
+ export const reverseSplit = data => {
45
+ data.forEach(split => {
43
46
  split.revert()
44
47
  })
45
48
  }