@linear_non/stellar-kit 1.1.8 → 2.0.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/README.md CHANGED
@@ -26,6 +26,7 @@ stellar-kit/
26
26
  ├── classes/ # Core logic: Manager, Component.
27
27
  ├── events/ # Emitter system: Raf, Resize, Scroll, Mouse, etc.
28
28
  ├── utils/ # Utilities: bounds, clamp, selectors, sniffer, etc.
29
+ ├── plugins/ # Helpers Grid, Observer, SplitText, etc.
29
30
  ├── kitStore.js # Central store shared across all modules
30
31
  └── index.js # Entry point for setupKit and kitStore access
31
32
  ```
@@ -45,8 +45,6 @@ export default class ImageLoader {
45
45
  }
46
46
  })
47
47
 
48
- console.log(urls)
49
-
50
48
  // cache-aware filter
51
49
  const toLoad = this.cache ? urls.filter(u => !this.cache.has(u)) : urls
52
50
  this.total = urls.length
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linear_non/stellar-kit",
3
- "version": "1.1.8",
3
+ "version": "2.0.0",
4
4
  "description": "Stellar frontend core for Non-Linear Studio projects.",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -8,6 +8,7 @@
8
8
  "./utils": "./utils/index.js",
9
9
  "./classes": "./classes/index.js",
10
10
  "./events": "./events/index.js",
11
+ "./plugins": "./plugins/index.js",
11
12
  "./gsap": "./libraries/gsap/index.js"
12
13
  },
13
14
  "type": "module",
@@ -19,6 +20,7 @@
19
20
  "files": [
20
21
  "classes/",
21
22
  "events/",
23
+ "plugins/",
22
24
  "utils/",
23
25
  "libraries/",
24
26
  "libraries/gsap/",
@@ -1,5 +1,5 @@
1
1
  import kitStore from "../kitStore"
2
- import { getWindowSizes } from "./window"
2
+ import { getWindowSizes } from "../utils/window"
3
3
  import { emitter, EVENTS } from "../events"
4
4
  import { gsap } from "../libraries/gsap"
5
5
 
@@ -0,0 +1,81 @@
1
+ // libs/observer/Observer.js
2
+ import { ScrollTrigger } from "@linear_non/stellar-kit/gsap"
3
+ import { Emitter } from "@linear_non/stellar-kit/events"
4
+
5
+ const DEFAULTS = {
6
+ trigger: null,
7
+ start: "top bottom",
8
+ end: "bottom top",
9
+ scrub: false,
10
+ markers: false,
11
+ }
12
+
13
+ export default class Observer extends Emitter {
14
+ constructor(opts = {}) {
15
+ super()
16
+ this.opts = { ...DEFAULTS, ...opts }
17
+ if (!this.opts.trigger) throw new Error("Observer: `trigger` is required")
18
+
19
+ this.st = ScrollTrigger.create({
20
+ trigger: this.opts.trigger,
21
+ start: this.opts.start,
22
+ end: this.opts.end,
23
+ scrub: this.opts.scrub,
24
+ markers: this.opts.markers,
25
+ onEnter: self => this.emit("enter", self, this),
26
+ onLeave: self => this.emit("leave", self, this),
27
+ onEnterBack: self => this.emit("enterBack", self, this),
28
+ onLeaveBack: self => this.emit("leaveBack", self, this),
29
+ onUpdate: self => this.emit("update", self, this),
30
+ })
31
+
32
+ if (this.opts.listeners) {
33
+ for (const [type, fn] of Object.entries(this.opts.listeners)) {
34
+ this.on(type, fn)
35
+ }
36
+ }
37
+ }
38
+
39
+ refresh() {
40
+ this.st?.refresh()
41
+ return this
42
+ }
43
+ enable() {
44
+ this.st?.enable()
45
+ return this
46
+ }
47
+ disable() {
48
+ this.st?.disable()
49
+ return this
50
+ }
51
+
52
+ // Update common vars at runtime (then refresh)
53
+ update({ start, end, scrub, markers } = {}) {
54
+ if (!this.st) return this
55
+ if (start !== undefined) this.st.vars.start = start
56
+ if (end !== undefined) this.st.vars.end = end
57
+ if (scrub !== undefined) this.st.vars.scrub = scrub
58
+ if (markers !== undefined) this.st.vars.markers = markers
59
+ this.st.refresh()
60
+ return this
61
+ }
62
+
63
+ // Clean up GSAP + all listeners from Emitter
64
+ kill() {
65
+ this.st?.kill()
66
+ this.st = null
67
+ this.destroy()
68
+ return this
69
+ }
70
+
71
+ // Handy getters
72
+ get progress() {
73
+ return this.st?.progress ?? 0
74
+ }
75
+ get isActive() {
76
+ return !!this.st?.isActive
77
+ }
78
+ get direction() {
79
+ return this.st?.direction ?? 1
80
+ }
81
+ }
@@ -0,0 +1,4 @@
1
+ import Grid from "../Grid"
2
+ import Observer from "./Observer"
3
+ export { splitText, reverseSplit } from "./SplitText"
4
+ export { Grid, Observer }
package/utils/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import Grid from "./grid"
2
1
  export { qs, qsa, getid, gettag } from "./selector"
3
2
  export { bounds } from "./bounds"
4
3
  export { offset } from "./offset"
@@ -7,5 +6,3 @@ export { sniffer } from "./sniffer"
7
6
  export { lerp, clamp, norm, round } from "./math"
8
7
  export { supportWebp, supportMouseTouch } from "./support"
9
8
  export { listener } from "./listener"
10
- export { splitText, reverseSplit } from "./splitText"
11
- export { Grid }
File without changes