@momo-kits/carousel 0.160.1-beta.10-test.1 → 0.160.1-beta.12
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/index.tsx +22 -4
- package/package.json +1 -1
package/index.tsx
CHANGED
|
@@ -361,6 +361,10 @@ const Carousel = forwardRef<CarouselRef, CarouselProps>((props, ref) => {
|
|
|
361
361
|
const realIndex = getRealIndex(index);
|
|
362
362
|
|
|
363
363
|
if (realIndex !== currentIndexRef.current) {
|
|
364
|
+
// eslint-disable-next-line no-console
|
|
365
|
+
console.log(
|
|
366
|
+
`[Carousel] SCROLL idx=${index} real=${realIndex} offsetX=${offsetX.toFixed(1)} layoutW=${layoutWidth.toFixed(1)} contentW=${contentWidth.toFixed(1)} itemWidth=${itemWidth.toFixed(1)} count=${dataWithClones.length}`
|
|
367
|
+
);
|
|
364
368
|
currentIndexRef.current = realIndex;
|
|
365
369
|
setCurrentIndex(realIndex);
|
|
366
370
|
|
|
@@ -369,7 +373,7 @@ const Carousel = forwardRef<CarouselRef, CarouselProps>((props, ref) => {
|
|
|
369
373
|
}
|
|
370
374
|
}
|
|
371
375
|
},
|
|
372
|
-
[resolveIndex, getRealIndex, onScrollIndexChanged]
|
|
376
|
+
[resolveIndex, getRealIndex, onScrollIndexChanged, itemWidth, dataWithClones.length]
|
|
373
377
|
);
|
|
374
378
|
|
|
375
379
|
const handleMomentumScrollEnd = useCallback(
|
|
@@ -384,6 +388,11 @@ const Carousel = forwardRef<CarouselRef, CarouselProps>((props, ref) => {
|
|
|
384
388
|
);
|
|
385
389
|
const realIndex = getRealIndex(index);
|
|
386
390
|
|
|
391
|
+
// eslint-disable-next-line no-console
|
|
392
|
+
console.log(
|
|
393
|
+
`[Carousel] MOMENTUM_END idx=${index} real=${realIndex} offsetX=${offsetX.toFixed(1)} layoutW=${layoutMeasurement.width.toFixed(1)} contentW=${contentSize.width.toFixed(1)} itemWidth=${itemWidth.toFixed(1)} count=${dataWithClones.length}`
|
|
394
|
+
);
|
|
395
|
+
|
|
387
396
|
// Report the final resting index here as well. The reanimated scroll
|
|
388
397
|
// handler isn't guaranteed to deliver the last momentum frame to JS in
|
|
389
398
|
// every runtime (e.g. miniapp hosts), so relying on handleScroll alone
|
|
@@ -407,7 +416,7 @@ const Carousel = forwardRef<CarouselRef, CarouselProps>((props, ref) => {
|
|
|
407
416
|
onMomentumScrollEndProp(event);
|
|
408
417
|
}
|
|
409
418
|
},
|
|
410
|
-
[resolveIndex, getRealIndex, onScrollIndexChanged, onSnapToItem, handleLoopReposition, onMomentumScrollEndProp]
|
|
419
|
+
[resolveIndex, getRealIndex, onScrollIndexChanged, onSnapToItem, handleLoopReposition, onMomentumScrollEndProp, itemWidth, dataWithClones.length]
|
|
411
420
|
);
|
|
412
421
|
|
|
413
422
|
const handleScrollEndDrag = useCallback(
|
|
@@ -424,6 +433,11 @@ const Carousel = forwardRef<CarouselRef, CarouselProps>((props, ref) => {
|
|
|
424
433
|
);
|
|
425
434
|
const realIndex = getRealIndex(index);
|
|
426
435
|
|
|
436
|
+
// eslint-disable-next-line no-console
|
|
437
|
+
console.log(
|
|
438
|
+
`[Carousel] DRAG_END idx=${index} real=${realIndex} offsetX=${contentOffset.x.toFixed(1)} layoutW=${layoutMeasurement.width.toFixed(1)} contentW=${contentSize.width.toFixed(1)} itemWidth=${itemWidth.toFixed(1)} count=${dataWithClones.length}`
|
|
439
|
+
);
|
|
440
|
+
|
|
427
441
|
if (realIndex !== currentIndexRef.current) {
|
|
428
442
|
currentIndexRef.current = realIndex;
|
|
429
443
|
setCurrentIndex(realIndex);
|
|
@@ -433,7 +447,7 @@ const Carousel = forwardRef<CarouselRef, CarouselProps>((props, ref) => {
|
|
|
433
447
|
}
|
|
434
448
|
}
|
|
435
449
|
},
|
|
436
|
-
[resolveIndex, getRealIndex, onScrollIndexChanged]
|
|
450
|
+
[resolveIndex, getRealIndex, onScrollIndexChanged, itemWidth, dataWithClones.length]
|
|
437
451
|
);
|
|
438
452
|
|
|
439
453
|
const handleTouchStart = useCallback(
|
|
@@ -463,6 +477,10 @@ const Carousel = forwardRef<CarouselRef, CarouselProps>((props, ref) => {
|
|
|
463
477
|
const handleLayout = useCallback(
|
|
464
478
|
(event: LayoutChangeEvent) => {
|
|
465
479
|
const { width } = event.nativeEvent.layout;
|
|
480
|
+
// eslint-disable-next-line no-console
|
|
481
|
+
console.log(
|
|
482
|
+
`[Carousel] LAYOUT width=${width.toFixed(1)} window=${viewportWidth.toFixed(1)} full=${full}`
|
|
483
|
+
);
|
|
466
484
|
containerWidthRef.current = width;
|
|
467
485
|
setContainerWidth(width);
|
|
468
486
|
setIsLayoutReady(true);
|
|
@@ -471,7 +489,7 @@ const Carousel = forwardRef<CarouselRef, CarouselProps>((props, ref) => {
|
|
|
471
489
|
onLayoutProp(event);
|
|
472
490
|
}
|
|
473
491
|
},
|
|
474
|
-
[onLayoutProp]
|
|
492
|
+
[onLayoutProp, full]
|
|
475
493
|
);
|
|
476
494
|
|
|
477
495
|
const getItemLayout = useCallback(
|