@linear_non/stellar-libs 1.0.40 → 1.0.42
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/src/Smooth/index.js +2 -11
- package/src/SplitOnScroll/index.js +37 -22
package/package.json
CHANGED
package/src/Smooth/index.js
CHANGED
|
@@ -13,8 +13,6 @@ export default class Smooth {
|
|
|
13
13
|
this.scrollbar = null
|
|
14
14
|
this.dpr = Math.max(1, Math.round(window.devicePixelRatio || 1))
|
|
15
15
|
|
|
16
|
-
this._resizeRaf = null
|
|
17
|
-
|
|
18
16
|
this.init()
|
|
19
17
|
}
|
|
20
18
|
|
|
@@ -123,15 +121,8 @@ export default class Smooth {
|
|
|
123
121
|
const { isSmooth } = kitStore.flags
|
|
124
122
|
if (!isSmooth) return
|
|
125
123
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this._resizeRaf = requestAnimationFrame(() => {
|
|
129
|
-
this._resizeRaf = null
|
|
130
|
-
|
|
131
|
-
this.update(this.elems)
|
|
132
|
-
|
|
133
|
-
emitter.emit(EVENTS.APP_SMOOTH_RESIZE)
|
|
134
|
-
})
|
|
124
|
+
this.update(this.elems)
|
|
125
|
+
emitter.emit(EVENTS.APP_SMOOTH_RESIZE)
|
|
135
126
|
}
|
|
136
127
|
|
|
137
128
|
update(elems) {
|
|
@@ -40,11 +40,13 @@ export default class SplitonScroll {
|
|
|
40
40
|
this._resolveReady = resolve
|
|
41
41
|
})
|
|
42
42
|
|
|
43
|
-
this.
|
|
44
|
-
|
|
45
|
-
this.
|
|
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.
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
addResizeListeners() {
|
|
90
|
+
// Raw resize start, clear split
|
|
91
|
+
this._offResizeStart = emitter.on(EVENTS.APP_RESIZE, this._onResizeStart, PRIORITY.first)
|
|
93
92
|
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
102
|
-
this.
|
|
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
|
-
|
|
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.
|
|
183
|
+
this.removeResizeListeners()
|
|
169
184
|
|
|
170
185
|
if (this.splits) {
|
|
171
186
|
reverseSplit(this.splits)
|