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.
@@ -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 ||