@linear_non/stellar-kit 2.1.17 → 2.1.18

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.
Files changed (2) hide show
  1. package/events/Raf.js +19 -0
  2. package/package.json +1 -1
package/events/Raf.js CHANGED
@@ -23,6 +23,23 @@ 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
+ if (!kitStore.flags.isSmooth) {
35
+ // native scroll mode: ensure the browser scroll is clamped too
36
+ const y = Math.min(window.scrollY, fh)
37
+ if (window.scrollY !== y) window.scrollTo(0, y)
38
+ }
39
+
40
+ ScrollTrigger.update()
41
+ }
42
+
26
43
  tick = () => {
27
44
  const { target, current, ease } = this.scroll
28
45
 
@@ -121,6 +138,7 @@ export default class Raf {
121
138
  gsap.ticker.add(this.tick)
122
139
  emitter.on(EVENTS.APP_SCROLL, this.onScroll)
123
140
  emitter.on(EVENTS.APP_MOUSEMOVE, this.onMouseMove)
141
+ emitter.on(EVENTS.APP_RESIZE, this.onAppResize)
124
142
  window.addEventListener("pagehide", () => this.stop)
125
143
  window.addEventListener("pageshow", () => this.resume)
126
144
  }
@@ -129,6 +147,7 @@ export default class Raf {
129
147
  gsap.ticker.remove(this.tick)
130
148
  emitter.off(EVENTS.APP_SCROLL, this.onScroll)
131
149
  emitter.off(EVENTS.APP_MOUSEMOVE, this.onMouseMove)
150
+ emitter.off(EVENTS.APP_RESIZE, this.onAppResize)
132
151
  window.removeEventListener("pagehide", () => this.stop)
133
152
  window.removeEventListener("pageshow", () => this.resume)
134
153
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linear_non/stellar-kit",
3
- "version": "2.1.17",
3
+ "version": "2.1.18",
4
4
  "description": "Stellar frontend core for Non-Linear Studio projects.",
5
5
  "main": "index.js",
6
6
  "exports": {