@linear_non/stellar-libs 1.0.39 → 1.0.41

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-libs",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "description": "Reusable JavaScript libraries for Non-Linear Studio projects.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -1,4 +1,4 @@
1
- import { EVENTS } from "@linear_non/stellar-kit/events"
1
+ import { EVENTS, PRIORITY, emitter } from "@linear_non/stellar-kit/events"
2
2
  import { Observer, reverseSplit, splitText } from "@linear_non/stellar-kit/plugins"
3
3
 
4
4
  const NOOP = () => {}
@@ -40,11 +40,13 @@ export default class SplitonScroll {
40
40
  this._resolveReady = resolve
41
41
  })
42
42
 
43
- this._onResize = this._onResize.bind(this)
44
- this._resizeScheduled = false
45
- this._offResize = null
43
+ this._needsResplit = false
44
+
45
+ this._onResizeStart = this._onResizeStart.bind(this)
46
+ this._onSmoothResize = this._onSmoothResize.bind(this)
47
+ this._offResizeStart = null
48
+ this._offSmoothResize = null
46
49
 
47
- // No element or no targets → resolve immediately once and bail
48
50
  if (!this.element || !this.targets.length) {
49
51
  const payload = { splits: [], groups: {} }
50
52
  this._notifyReadyOnce(payload)
@@ -52,9 +54,8 @@ export default class SplitonScroll {
52
54
  }
53
55
 
54
56
  this.addObserver()
55
- this.addResizeListener()
57
+ this.addResizeListeners()
56
58
 
57
- // If already in view on init, run enter logic once
58
59
  if (this.observer && (this.observer.isActive || this.observer.progress > 0)) {
59
60
  this.handleEnter()
60
61
  }
@@ -64,10 +65,8 @@ export default class SplitonScroll {
64
65
  if (this._readyNotified) return
65
66
  this._readyNotified = true
66
67
 
67
- // external callback
68
68
  this.isReadyCallback(payload.splits, payload.groups)
69
69
 
70
- // external promise
71
70
  if (this._resolveReady) {
72
71
  this._resolveReady(payload)
73
72
  this._resolveReady = null
@@ -87,36 +86,51 @@ export default class SplitonScroll {
87
86
  this.observer.on("leave", () => this.handleLeave())
88
87
  }
89
88
 
90
- addResizeListener() {
91
- this._offResize = emitter.on(EVENTS.APP_RESIZE, this._onResize, PRIORITY.first)
92
- }
89
+ addResizeListeners() {
90
+ // Raw resize start, clear split
91
+ this._offResizeStart = emitter.on(EVENTS.APP_RESIZE, this._onResizeStart, PRIORITY.first)
93
92
 
94
- removeResizeListener() {
95
- if (this._offResize) {
96
- this._offResize()
97
- this._offResize = null
98
- }
93
+ // Smooth.update() + setScrollBounds()
94
+ this._offSmoothResize = emitter.on(EVENTS.APP_SMOOTH_RESIZE, this._onSmoothResize)
99
95
  }
100
96
 
101
- _onResize() {
102
- this._handleResizeInternal()
97
+ removeResizeListeners() {
98
+ if (this._offResizeStart) {
99
+ this._offResizeStart()
100
+ this._offResizeStart = null
101
+ }
102
+ if (this._offSmoothResize) {
103
+ this._offSmoothResize()
104
+ this._offSmoothResize = null
105
+ }
103
106
  }
104
107
 
105
- _handleResizeInternal() {
108
+ _onResizeStart() {
106
109
  if (!this.element || !this.targets || !this.targets.length) return
107
110
 
108
111
  if (this.splits) {
109
112
  reverseSplit(this.splits)
113
+
114
+ this.splits = null
115
+ this.groups = null
110
116
  }
111
117
 
118
+ this._needsResplit = true
119
+ }
120
+
121
+ _onSmoothResize() {
122
+ if (!this._needsResplit) return
123
+ if (!this.element || !this.targets || !this.targets.length) return
124
+
112
125
  if (this.observer && typeof this.observer.refresh === "function") {
113
126
  this.observer.refresh()
114
127
  }
115
128
 
116
- // If in view after resize, re-split; external callback will *not* re-fire
117
129
  if (this.observer && (this.observer.isActive || this.observer.progress > 0)) {
118
130
  this.handleEnter()
119
131
  }
132
+
133
+ this._needsResplit = false
120
134
  }
121
135
 
122
136
  async handleEnter() {
@@ -143,13 +157,14 @@ export default class SplitonScroll {
143
157
  this.splits = splits
144
158
  this.groups = groups
145
159
 
146
- // First time → notify + resolve; later (resize, re-enter) → no-op
147
160
  this._notifyReadyOnce({ splits, groups })
148
161
  }
149
162
 
150
163
  handleLeave() {
151
164
  if (this.splits) {
152
165
  reverseSplit(this.splits)
166
+ this.splits = null
167
+ this.groups = null
153
168
  }
154
169
 
155
170
  this.reverseCallback()
@@ -165,7 +180,7 @@ export default class SplitonScroll {
165
180
 
166
181
  destroy() {
167
182
  this.observer?.kill()
168
- this.removeResizeListener()
183
+ this.removeResizeListeners()
169
184
 
170
185
  if (this.splits) {
171
186
  reverseSplit(this.splits)