@linear_non/stellar-kit 2.0.1 → 2.1.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/events/Resize.js CHANGED
@@ -2,7 +2,8 @@
2
2
  import { sizes, flags, breakpoints } from "../kitStore"
3
3
  import emitter, { EVENTS } from "./Emitter"
4
4
  import debounce from "lodash.debounce"
5
- import { sniffer, getWindowSizes, getViewport, setViewportHeight } from "../utils"
5
+ import { sniffer, getWindowSizes, getViewport, setViewportHeight, raf2 } from "../utils"
6
+ import { ScrollTrigger } from "../libraries/gsap"
6
7
 
7
8
  export default class Resize {
8
9
  constructor() {
@@ -35,7 +36,14 @@ export default class Resize {
35
36
  this.reloadIfBreakpointChanged()
36
37
 
37
38
  emitter.emit(EVENTS.APP_RESIZE)
39
+ ScrollTrigger.refresh()
40
+ flags.isResizing = false
41
+ }
38
42
 
43
+ onLoadOnce = () => {
44
+ flags.isResizing = true
45
+ emitter.emit(EVENTS.APP_RESIZE)
46
+ ScrollTrigger.refresh()
39
47
  flags.isResizing = false
40
48
  }
41
49
 
@@ -64,6 +72,7 @@ export default class Resize {
64
72
 
65
73
  on() {
66
74
  window.addEventListener("resize", debounce(this.onResize, 200))
75
+ window.addEventListener("load", this.onLoadOnce, { once: true })
67
76
  }
68
77
 
69
78
  init() {
package/kitStore.js CHANGED
@@ -14,6 +14,7 @@ export const flags = {
14
14
  isFocus: false,
15
15
  isSmooth: false,
16
16
  isResizing: false,
17
+ isDebug: false,
17
18
  // ... optionally others
18
19
  }
19
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linear_non/stellar-kit",
3
- "version": "2.0.1",
3
+ "version": "2.1.2",
4
4
  "description": "Stellar frontend core for Non-Linear Studio projects.",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -49,7 +49,6 @@ export default class Observer extends Emitter {
49
49
  return this
50
50
  }
51
51
 
52
- // Update common vars at runtime (then refresh)
53
52
  update({ start, end, scrub, markers } = {}) {
54
53
  if (!this.st) return this
55
54
  if (start !== undefined) this.st.vars.start = start
@@ -60,7 +59,6 @@ export default class Observer extends Emitter {
60
59
  return this
61
60
  }
62
61
 
63
- // Clean up GSAP + all listeners from Emitter
64
62
  kill() {
65
63
  this.st?.kill()
66
64
  this.st = null
package/utils/index.js CHANGED
@@ -6,3 +6,4 @@ export { sniffer } from "./sniffer"
6
6
  export { lerp, clamp, norm, round } from "./math"
7
7
  export { supportWebp, supportMouseTouch } from "./support"
8
8
  export { listener } from "./listener"
9
+ export { raf2 } from "./timing"
@@ -0,0 +1,2 @@
1
+ // utils/timing.js
2
+ export const raf2 = cb => requestAnimationFrame(() => requestAnimationFrame(cb))