react-native-reanimated-carousel 2.3.0 → 2.3.2-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 (52) hide show
  1. package/README.md +8 -0
  2. package/lib/commonjs/Carousel.js +1 -1
  3. package/lib/commonjs/Carousel.js.map +1 -1
  4. package/lib/commonjs/ScrollViewGesture.js +1 -1
  5. package/lib/commonjs/ScrollViewGesture.js.map +1 -1
  6. package/lib/commonjs/constants/index.js.map +1 -1
  7. package/lib/commonjs/hooks/useCarouselController.js.map +1 -1
  8. package/lib/commonjs/hooks/useCheckMounted.js +2 -0
  9. package/lib/commonjs/hooks/useCheckMounted.js.map +1 -0
  10. package/lib/commonjs/hooks/useInitProps.js +1 -1
  11. package/lib/commonjs/hooks/useInitProps.js.map +1 -1
  12. package/lib/commonjs/layouts/BaseLayout.js +1 -1
  13. package/lib/commonjs/layouts/BaseLayout.js.map +1 -1
  14. package/lib/commonjs/layouts/ParallaxLayout.js +1 -1
  15. package/lib/commonjs/layouts/ParallaxLayout.js.map +1 -1
  16. package/lib/commonjs/layouts/parallax.js +1 -1
  17. package/lib/commonjs/layouts/parallax.js.map +1 -1
  18. package/lib/commonjs/layouts/stack.js +1 -1
  19. package/lib/commonjs/layouts/stack.js.map +1 -1
  20. package/lib/module/Carousel.js +10 -7
  21. package/lib/module/Carousel.js.map +1 -1
  22. package/lib/module/ScrollViewGesture.js +6 -1
  23. package/lib/module/ScrollViewGesture.js.map +1 -1
  24. package/lib/module/constants/index.js.map +1 -1
  25. package/lib/module/hooks/useCarouselController.js +8 -4
  26. package/lib/module/hooks/useCarouselController.js.map +1 -1
  27. package/lib/module/hooks/useCheckMounted.js +12 -0
  28. package/lib/module/hooks/useCheckMounted.js.map +1 -0
  29. package/lib/module/layouts/BaseLayout.js +4 -2
  30. package/lib/module/layouts/BaseLayout.js.map +1 -1
  31. package/lib/module/layouts/ParallaxLayout.js +2 -1
  32. package/lib/module/layouts/ParallaxLayout.js.map +1 -1
  33. package/lib/module/layouts/parallax.js +5 -3
  34. package/lib/module/layouts/parallax.js.map +1 -1
  35. package/lib/module/layouts/stack.js +7 -3
  36. package/lib/module/layouts/stack.js.map +1 -1
  37. package/lib/module/utils/log.js +2 -2
  38. package/lib/module/utils/log.js.map +1 -1
  39. package/lib/typescript/constants/index.d.ts +2 -1
  40. package/lib/typescript/hooks/useCheckMounted.d.ts +2 -0
  41. package/lib/typescript/layouts/ParallaxLayout.d.ts +2 -3
  42. package/lib/typescript/layouts/parallax.d.ts +8 -3
  43. package/lib/typescript/types.d.ts +4 -2
  44. package/package.json +4 -2
  45. package/src/ScrollViewGesture.tsx +8 -3
  46. package/src/constants/index.ts +7 -2
  47. package/src/hooks/useCarouselController.tsx +2 -2
  48. package/src/hooks/useCheckMounted.ts +14 -0
  49. package/src/layouts/BaseLayout.tsx +8 -5
  50. package/src/layouts/ParallaxLayout.tsx +13 -11
  51. package/src/layouts/parallax.ts +15 -7
  52. package/src/types.ts +11 -9
@@ -6,17 +6,22 @@ type TBaseConfig = {
6
6
  vertical: boolean;
7
7
  };
8
8
 
9
- interface ILayoutConfig {
9
+ export interface ILayoutConfig {
10
10
  /**
11
- * When use default Layout props,this prop can be control prev/next item offset.
11
+ * control prev/next item offset.
12
12
  * @default 100
13
13
  */
14
14
  parallaxScrollingOffset?: number;
15
15
  /**
16
- * When use default Layout props,this prop can be control prev/next item offset.
16
+ * control prev/current/next item offset.
17
17
  * @default 0.8
18
18
  */
19
19
  parallaxScrollingScale?: number;
20
+ /**
21
+ * control prev/next item offset.
22
+ * @default Math.pow(parallaxScrollingScale, 2)
23
+ */
24
+ parallaxAdjacentItemScale?: number;
20
25
  }
21
26
 
22
27
  export type TParallaxModeProps = ComputedDirectionTypes<{
@@ -32,8 +37,11 @@ export function parallaxLayout(
32
37
  modeConfig: ILayoutConfig = {}
33
38
  ) {
34
39
  const { size, vertical } = baseConfig;
35
- const { parallaxScrollingOffset = 100, parallaxScrollingScale = 0.8 } =
36
- modeConfig;
40
+ const {
41
+ parallaxScrollingOffset = 100,
42
+ parallaxScrollingScale = 0.8,
43
+ parallaxAdjacentItemScale = Math.pow(parallaxScrollingScale, 2),
44
+ } = modeConfig;
37
45
 
38
46
  return (value: number) => {
39
47
  'worklet';
@@ -54,9 +62,9 @@ export function parallaxLayout(
54
62
  value,
55
63
  [-1, 0, 1],
56
64
  [
57
- Math.pow(parallaxScrollingScale, 2),
65
+ parallaxAdjacentItemScale,
58
66
  parallaxScrollingScale,
59
- Math.pow(parallaxScrollingScale, 2),
67
+ parallaxAdjacentItemScale,
60
68
  ],
61
69
  Extrapolate.CLAMP
62
70
  );
package/src/types.ts CHANGED
@@ -46,15 +46,17 @@ export type CustomConfig = {
46
46
  viewCount?: number;
47
47
  };
48
48
 
49
- export type WithAnimation =
50
- | {
51
- type: 'spring';
52
- config: WithSpringConfig;
53
- }
54
- | {
55
- type: 'timing';
56
- config: WithTimingConfig;
57
- };
49
+ export type WithSpringAnimation = {
50
+ type: 'spring';
51
+ config: WithSpringConfig;
52
+ };
53
+
54
+ export type WithTimingAnimation = {
55
+ type: 'timing';
56
+ config: WithTimingConfig;
57
+ };
58
+
59
+ export type WithAnimation = WithSpringAnimation | WithTimingAnimation;
58
60
 
59
61
  export type TCarouselProps<T = any> = {
60
62
  ref?: React.Ref<ICarouselInstance>;