@momo-kits/carousel 0.164.1-test.10 → 0.165.1-beta.1

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.
Files changed (40) hide show
  1. package/animation.ts +62 -0
  2. package/index.tsx +455 -390
  3. package/package.json +6 -7
  4. package/types.ts +48 -123
  5. package/core/LICENSE +0 -21
  6. package/core/README.md +0 -16
  7. package/core/components/Carousel.tsx +0 -28
  8. package/core/components/CarouselLayout.tsx +0 -231
  9. package/core/components/ItemLayout.tsx +0 -215
  10. package/core/components/ItemRenderer.tsx +0 -126
  11. package/core/components/LazyView.tsx +0 -14
  12. package/core/components/ScrollViewGesture.tsx +0 -443
  13. package/core/constants/index.ts +0 -11
  14. package/core/hooks/useAutoPlay.ts +0 -63
  15. package/core/hooks/useCarouselController.tsx +0 -295
  16. package/core/hooks/useCheckMounted.ts +0 -14
  17. package/core/hooks/useCommonVariables.ts +0 -261
  18. package/core/hooks/useInitProps.ts +0 -177
  19. package/core/hooks/useLayoutConfig.ts +0 -35
  20. package/core/hooks/useOffsetX.ts +0 -81
  21. package/core/hooks/useOnProgressChange.ts +0 -33
  22. package/core/hooks/usePanGestureProxy.ts +0 -144
  23. package/core/hooks/usePropsErrorBoundary.ts +0 -41
  24. package/core/hooks/useUpdateGestureConfig.ts +0 -17
  25. package/core/hooks/useVisibleRanges.tsx +0 -141
  26. package/core/layouts/index.tsx +0 -10
  27. package/core/layouts/normal.ts +0 -32
  28. package/core/layouts/parallax.ts +0 -50
  29. package/core/layouts/stack.ts +0 -266
  30. package/core/public-types.ts +0 -209
  31. package/core/store/index.tsx +0 -63
  32. package/core/types.ts +0 -32
  33. package/core/utils/carousel-direction.ts +0 -39
  34. package/core/utils/carousel-math.ts +0 -156
  35. package/core/utils/compute-gesture-translation.ts +0 -29
  36. package/core/utils/compute-offset-if-size-changed.ts +0 -14
  37. package/core/utils/computed-with-auto-fill-data.ts +0 -92
  38. package/core/utils/deal-with-animation.ts +0 -19
  39. package/core/utils/log.ts +0 -12
  40. package/core/utils/sanitize-animation-style.ts +0 -20
package/animation.ts ADDED
@@ -0,0 +1,62 @@
1
+ import {ReactNode} from 'react';
2
+ import {Animated} from 'react-native';
3
+ import {CarouselProps} from './types';
4
+
5
+ export function getInputRangeFromIndexes(
6
+ range: string | any[],
7
+ index: number,
8
+ itemWidth: number,
9
+ ) {
10
+ const sizeRef = itemWidth;
11
+ const inputRange = [];
12
+
13
+ for (let i = 0; i < range.length; i++) {
14
+ inputRange.push((index - range[i]) * sizeRef);
15
+ }
16
+
17
+ return inputRange;
18
+ }
19
+
20
+ export function defaultScrollInterpolator(index: number, itemWidth: number) {
21
+ const range = [1, 0, -1];
22
+ const inputRange = getInputRangeFromIndexes(range, index, itemWidth);
23
+ const outputRange = [0, 1, 0];
24
+
25
+ return {inputRange, outputRange};
26
+ }
27
+
28
+ export function defaultAnimatedStyles(
29
+ animatedValue: Animated.Value,
30
+ carouselProps: Readonly<CarouselProps> & Readonly<{children?: ReactNode}>,
31
+ ) {
32
+ let animatedOpacity = {};
33
+ let animatedScale = {};
34
+ const {inactiveSlideOpacity = 1, inactiveSlideScale = 1} = carouselProps;
35
+
36
+ if (inactiveSlideOpacity < 1) {
37
+ animatedOpacity = {
38
+ opacity: animatedValue.interpolate({
39
+ inputRange: [0, 1],
40
+ outputRange: [inactiveSlideOpacity, 1],
41
+ }),
42
+ };
43
+ }
44
+
45
+ if (inactiveSlideScale < 1) {
46
+ animatedScale = {
47
+ transform: [
48
+ {
49
+ scaleY: animatedValue.interpolate({
50
+ inputRange: [0, 1],
51
+ outputRange: [inactiveSlideScale, 1],
52
+ }),
53
+ },
54
+ ],
55
+ };
56
+ }
57
+
58
+ return {
59
+ ...animatedOpacity,
60
+ ...animatedScale,
61
+ };
62
+ }