mtrl-addons 0.2.1 → 0.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/AI.md +28 -230
- package/CLAUDE.md +882 -0
- package/build.js +286 -110
- package/package.json +2 -1
- package/src/components/vlist/features/api.ts +316 -12
- package/src/components/vlist/features/selection.ts +248 -256
- package/src/components/vlist/features/viewport.ts +1 -7
- package/src/components/vlist/index.ts +1 -0
- package/src/components/vlist/types.ts +140 -8
- package/src/core/layout/schema.ts +81 -38
- package/src/core/viewport/constants.ts +7 -2
- package/src/core/viewport/features/collection.ts +376 -76
- package/src/core/viewport/features/item-size.ts +4 -4
- package/src/core/viewport/features/momentum.ts +11 -2
- package/src/core/viewport/features/rendering.ts +424 -30
- package/src/core/viewport/features/scrolling.ts +41 -25
- package/src/core/viewport/features/utils.ts +11 -5
- package/src/core/viewport/features/virtual.ts +169 -28
- package/src/core/viewport/types.ts +2 -2
- package/src/core/viewport/viewport.ts +29 -10
- package/src/styles/components/_vlist.scss +234 -213
|
@@ -9,7 +9,7 @@ export interface ItemSizeManager {
|
|
|
9
9
|
measureItem(
|
|
10
10
|
element: HTMLElement,
|
|
11
11
|
index: number,
|
|
12
|
-
orientation?: "vertical" | "horizontal"
|
|
12
|
+
orientation?: "vertical" | "horizontal",
|
|
13
13
|
): number;
|
|
14
14
|
|
|
15
15
|
// Cache management
|
|
@@ -44,7 +44,7 @@ export interface ItemSizeConfig {
|
|
|
44
44
|
* Creates an item size manager for measuring and caching item dimensions
|
|
45
45
|
*/
|
|
46
46
|
export const createItemSizeManager = (
|
|
47
|
-
config: ItemSizeConfig = {}
|
|
47
|
+
config: ItemSizeConfig = {},
|
|
48
48
|
): ItemSizeManager => {
|
|
49
49
|
const {
|
|
50
50
|
initialEstimate = 60,
|
|
@@ -116,7 +116,7 @@ export const createItemSizeManager = (
|
|
|
116
116
|
const measureItem = (
|
|
117
117
|
element: HTMLElement,
|
|
118
118
|
index: number,
|
|
119
|
-
measureOrientation?: "vertical" | "horizontal"
|
|
119
|
+
measureOrientation?: "vertical" | "horizontal",
|
|
120
120
|
): number => {
|
|
121
121
|
if (!element || index < 0) {
|
|
122
122
|
return currentItemSize;
|
|
@@ -182,7 +182,7 @@ export const createItemSizeManager = (
|
|
|
182
182
|
// Calculate based on measured items only
|
|
183
183
|
return Array.from(measuredSizes.values()).reduce(
|
|
184
184
|
(sum, size) => sum + size,
|
|
185
|
-
0
|
|
185
|
+
0,
|
|
186
186
|
);
|
|
187
187
|
}
|
|
188
188
|
|
|
@@ -45,11 +45,16 @@ export const withMomentum = (config: MomentumConfig = {}) => {
|
|
|
45
45
|
// Get references after initialization
|
|
46
46
|
const originalInitialize = component.viewport.initialize;
|
|
47
47
|
component.viewport.initialize = () => {
|
|
48
|
-
originalInitialize();
|
|
48
|
+
const result = originalInitialize();
|
|
49
|
+
// Skip if already initialized
|
|
50
|
+
if (result === false) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
49
53
|
|
|
50
54
|
// Get viewport and scrolling states
|
|
51
55
|
viewportState = (component.viewport as any).state;
|
|
52
56
|
scrollingState = (component.viewport as any).scrollingState;
|
|
57
|
+
return result;
|
|
53
58
|
};
|
|
54
59
|
|
|
55
60
|
// Start momentum animation
|
|
@@ -200,7 +205,11 @@ export const withMomentum = (config: MomentumConfig = {}) => {
|
|
|
200
205
|
// Override initialize to add event listeners
|
|
201
206
|
const originalInit = component.viewport.initialize;
|
|
202
207
|
component.viewport.initialize = () => {
|
|
203
|
-
originalInit();
|
|
208
|
+
const result = originalInit();
|
|
209
|
+
// Skip if already initialized
|
|
210
|
+
if (result === false) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
204
213
|
|
|
205
214
|
const viewportElement =
|
|
206
215
|
(component as any).viewportElement ||
|