@linear_non/stellar-kit 3.0.6 → 3.0.8
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/core/PageEngine.js +21 -16
- package/package.json +1 -1
package/core/PageEngine.js
CHANGED
|
@@ -23,16 +23,27 @@ import { ScrollTrigger } from "../libraries/gsap/index.js"
|
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* @typedef {Object} EngineSetupConfig
|
|
26
|
-
* @property {Array<any>} components - Array of component constructors/definitions.
|
|
27
|
-
* @property {Object} [lenis] - Lenis instance
|
|
28
|
-
* @property {HTMLElement} [wrapper] - Scroll wrapper element (required
|
|
29
|
-
* @property {
|
|
26
|
+
* @property {Array<any>} [components] - Array of component constructors/definitions.
|
|
27
|
+
* @property {Object} [lenis] - Lenis instance for external scroll mode.
|
|
28
|
+
* @property {HTMLElement} [wrapper] - Scroll wrapper element (required with lenis).
|
|
29
|
+
* @property {Object} [smooth] - Smooth instance for internal scroll mode.
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Unified page engine that handles both internal scroll and Lenis modes.
|
|
34
|
-
*
|
|
35
|
-
*
|
|
34
|
+
*
|
|
35
|
+
* Usage:
|
|
36
|
+
* ```js
|
|
37
|
+
* // Lenis mode
|
|
38
|
+
* const wrapper = getid("main")
|
|
39
|
+
* const content = qs(".-page")
|
|
40
|
+
* const lenis = await createLenis(wrapper, content)
|
|
41
|
+
* engine.setup({ components, lenis, wrapper })
|
|
42
|
+
*
|
|
43
|
+
* // Internal mode
|
|
44
|
+
* const smooth = createSmooth(Smooth)
|
|
45
|
+
* engine.setup({ components, smooth })
|
|
46
|
+
* ```
|
|
36
47
|
*/
|
|
37
48
|
export default class PageEngine {
|
|
38
49
|
/**
|
|
@@ -49,11 +60,6 @@ export default class PageEngine {
|
|
|
49
60
|
*/
|
|
50
61
|
this.components = []
|
|
51
62
|
|
|
52
|
-
/**
|
|
53
|
-
* @type {number}
|
|
54
|
-
*/
|
|
55
|
-
this.componentsLength = 0
|
|
56
|
-
|
|
57
63
|
/**
|
|
58
64
|
* @type {Manager | null}
|
|
59
65
|
*/
|
|
@@ -101,8 +107,7 @@ export default class PageEngine {
|
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
/**
|
|
104
|
-
* Setup the engine with components and
|
|
105
|
-
* Auto-detects Lenis mode if `lenis` is provided.
|
|
110
|
+
* Setup the engine with components and scroll system.
|
|
106
111
|
*
|
|
107
112
|
* @param {EngineSetupConfig} param0
|
|
108
113
|
*/
|
|
@@ -111,11 +116,10 @@ export default class PageEngine {
|
|
|
111
116
|
|
|
112
117
|
this.components = components || []
|
|
113
118
|
|
|
119
|
+
// Setup scroll system
|
|
114
120
|
if (lenis && wrapper) {
|
|
115
|
-
// Lenis mode: auto-configure ticker and ScrollTrigger
|
|
116
121
|
this._setupLenis(lenis, wrapper)
|
|
117
122
|
} else if (smooth) {
|
|
118
|
-
// Legacy: smooth instance passed directly
|
|
119
123
|
this.smooth = smooth
|
|
120
124
|
}
|
|
121
125
|
|
|
@@ -128,11 +132,12 @@ export default class PageEngine {
|
|
|
128
132
|
}
|
|
129
133
|
|
|
130
134
|
this.manager.initialize()
|
|
131
|
-
this.manager.animateIn?.()
|
|
132
135
|
|
|
133
136
|
this.on()
|
|
134
137
|
this.trackImages()
|
|
135
138
|
this.resize()
|
|
139
|
+
|
|
140
|
+
this.manager.animateIn?.()
|
|
136
141
|
}
|
|
137
142
|
|
|
138
143
|
/**
|