@linear_non/stellar-libs 1.2.0 → 1.2.2
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 +8 -43
- package/src/Sticky/index.js +2 -0
package/package.json
CHANGED
package/src/Smooth/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Scrollbar from "../ScrollBar"
|
|
2
2
|
import { kitStore } from "@linear_non/stellar-kit"
|
|
3
3
|
import { emitter, EVENTS } from "@linear_non/stellar-kit/events"
|
|
4
|
-
import { qs, qsa, bounds } from "@linear_non/stellar-kit/utils"
|
|
4
|
+
import { qs, qsa, bounds, Debug } from "@linear_non/stellar-kit/utils"
|
|
5
5
|
|
|
6
6
|
export default class Smooth {
|
|
7
7
|
constructor(obj) {
|
|
@@ -12,7 +12,6 @@ export default class Smooth {
|
|
|
12
12
|
this.sections = null
|
|
13
13
|
this.scrollbar = null
|
|
14
14
|
this.dpr = Math.max(1, Math.round(window.devicePixelRatio || 1))
|
|
15
|
-
this.resizeRAF = null
|
|
16
15
|
|
|
17
16
|
this.init()
|
|
18
17
|
}
|
|
@@ -110,49 +109,20 @@ export default class Smooth {
|
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
resetTransforms() {
|
|
114
|
-
if (!this.elems) return
|
|
115
|
-
this.elems.forEach(el => {
|
|
116
|
-
el.style.transform = ""
|
|
117
|
-
})
|
|
118
|
-
}
|
|
119
|
-
|
|
120
112
|
resize = () => {
|
|
121
113
|
const { isSmooth } = kitStore.flags
|
|
122
114
|
|
|
123
115
|
if (!isSmooth) return
|
|
124
116
|
|
|
125
|
-
|
|
126
|
-
if (this.resizeRAF) {
|
|
127
|
-
cancelAnimationFrame(this.resizeRAF)
|
|
128
|
-
this.resizeRAF = null
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Clear transforms to get accurate measurements
|
|
132
|
-
this.resetTransforms()
|
|
133
|
-
|
|
134
|
-
// Force reflow
|
|
135
|
-
if (this.el) {
|
|
136
|
-
void this.el.offsetHeight
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Double RAF to ensure DOM has fully reflowed
|
|
140
|
-
this.resizeRAF = requestAnimationFrame(() => {
|
|
141
|
-
this.resizeRAF = requestAnimationFrame(() => {
|
|
142
|
-
this.resizeRAF = null
|
|
117
|
+
this.scroll?.setScrollBounds()
|
|
143
118
|
|
|
144
|
-
|
|
119
|
+
const { fh } = kitStore.sizes
|
|
120
|
+
this.current = Math.min(Math.max(this.current, 0), fh || 0)
|
|
145
121
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
emitter.emit(EVENTS.APP_SMOOTH_RESIZE)
|
|
152
|
-
this.transformSections()
|
|
153
|
-
this.scrollbar?.update()
|
|
154
|
-
})
|
|
155
|
-
})
|
|
122
|
+
this.getSections()
|
|
123
|
+
emitter.emit(EVENTS.APP_SMOOTH_RESIZE)
|
|
124
|
+
this.transformSections()
|
|
125
|
+
this.scrollbar?.update()
|
|
156
126
|
}
|
|
157
127
|
|
|
158
128
|
update(elems) {
|
|
@@ -182,11 +152,6 @@ export default class Smooth {
|
|
|
182
152
|
}
|
|
183
153
|
|
|
184
154
|
destroy() {
|
|
185
|
-
if (this.resizeRAF) {
|
|
186
|
-
cancelAnimationFrame(this.resizeRAF)
|
|
187
|
-
this.resizeRAF = null
|
|
188
|
-
}
|
|
189
|
-
|
|
190
155
|
this.off()
|
|
191
156
|
this.scrollbar?.destroy()
|
|
192
157
|
this.clean()
|
package/src/Sticky/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Sticky.js
|
|
2
2
|
import { bounds } from "@linear_non/stellar-kit/utils"
|
|
3
3
|
import { gsap, ScrollTrigger } from "@linear_non/stellar-kit/gsap"
|
|
4
|
+
import { kitStore } from "@linear_non/stellar-kit/kitStore"
|
|
4
5
|
|
|
5
6
|
export default class Sticky {
|
|
6
7
|
constructor(obj) {
|
|
@@ -36,6 +37,7 @@ export default class Sticky {
|
|
|
36
37
|
start: "top top",
|
|
37
38
|
end: "bottom bottom",
|
|
38
39
|
scrub: true,
|
|
40
|
+
scroller: kitStore.scroller || undefined,
|
|
39
41
|
onEnter: () => this.toggleSticky(true),
|
|
40
42
|
onEnterBack: () => this.toggleSticky(true),
|
|
41
43
|
onLeave: () => this.toggleSticky(false, true),
|