@linear_non/stellar-kit 2.1.17 → 2.1.19
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/Raf.js +13 -0
- package/events/Resize.js +1 -12
- package/package.json +1 -1
package/events/Raf.js
CHANGED
|
@@ -23,6 +23,17 @@ export default class Raf {
|
|
|
23
23
|
this.on()
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
onAppResize = () => {
|
|
27
|
+
const { fh } = kitStore.sizes
|
|
28
|
+
|
|
29
|
+
// clamp our smooth state
|
|
30
|
+
this.scroll.target = Math.min(Math.max(this.scroll.target, 0), fh)
|
|
31
|
+
this.scroll.current = Math.min(Math.max(this.scroll.current, 0), fh)
|
|
32
|
+
this.scroll.rounded = Math.min(Math.max(this.scroll.rounded, 0), fh)
|
|
33
|
+
|
|
34
|
+
ScrollTrigger.update()
|
|
35
|
+
}
|
|
36
|
+
|
|
26
37
|
tick = () => {
|
|
27
38
|
const { target, current, ease } = this.scroll
|
|
28
39
|
|
|
@@ -121,6 +132,7 @@ export default class Raf {
|
|
|
121
132
|
gsap.ticker.add(this.tick)
|
|
122
133
|
emitter.on(EVENTS.APP_SCROLL, this.onScroll)
|
|
123
134
|
emitter.on(EVENTS.APP_MOUSEMOVE, this.onMouseMove)
|
|
135
|
+
emitter.on(EVENTS.APP_RESIZE, this.onAppResize)
|
|
124
136
|
window.addEventListener("pagehide", () => this.stop)
|
|
125
137
|
window.addEventListener("pageshow", () => this.resume)
|
|
126
138
|
}
|
|
@@ -129,6 +141,7 @@ export default class Raf {
|
|
|
129
141
|
gsap.ticker.remove(this.tick)
|
|
130
142
|
emitter.off(EVENTS.APP_SCROLL, this.onScroll)
|
|
131
143
|
emitter.off(EVENTS.APP_MOUSEMOVE, this.onMouseMove)
|
|
144
|
+
emitter.off(EVENTS.APP_RESIZE, this.onAppResize)
|
|
132
145
|
window.removeEventListener("pagehide", () => this.stop)
|
|
133
146
|
window.removeEventListener("pageshow", () => this.resume)
|
|
134
147
|
}
|
package/events/Resize.js
CHANGED
|
@@ -71,18 +71,7 @@ export default class Resize {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
on() {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const handler = () => {
|
|
77
|
-
if (scheduled) return
|
|
78
|
-
scheduled = true
|
|
79
|
-
requestAnimationFrame(() => {
|
|
80
|
-
scheduled = false
|
|
81
|
-
this.onResize()
|
|
82
|
-
})
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
window.addEventListener("resize", debounce(handler, 200), { passive: true })
|
|
74
|
+
window.addEventListener("resize", debounce(this.onResize, 200), { passive: true })
|
|
86
75
|
window.addEventListener("load", this.onLoadOnce, { once: true })
|
|
87
76
|
}
|
|
88
77
|
|