@fountain-ui/lab 2.0.0-beta.12 → 2.0.0-beta.13

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 (69) hide show
  1. package/build/commonjs/Carousel/Carousel.js +12 -7
  2. package/build/commonjs/Carousel/Carousel.js.map +1 -1
  3. package/build/commonjs/Carousel/CarouselProps.js.map +1 -1
  4. package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js +13 -13
  5. package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js.map +1 -1
  6. package/build/commonjs/Carousel/components/InternalContext.js.map +1 -1
  7. package/build/commonjs/Carousel/components/ItemView.js +4 -2
  8. package/build/commonjs/Carousel/components/ItemView.js.map +1 -1
  9. package/build/commonjs/Carousel/components/RootView.js +21 -3
  10. package/build/commonjs/Carousel/components/RootView.js.map +1 -1
  11. package/build/commonjs/Carousel/components/ScrollViewGesture.js +12 -7
  12. package/build/commonjs/Carousel/components/ScrollViewGesture.js.map +1 -1
  13. package/build/commonjs/Carousel/hooks/useAutoplayController.js +4 -1
  14. package/build/commonjs/Carousel/hooks/useAutoplayController.js.map +1 -1
  15. package/build/commonjs/Carousel/hooks/usePagingAnimation.js +57 -19
  16. package/build/commonjs/Carousel/hooks/usePagingAnimation.js.map +1 -1
  17. package/build/commonjs/Carousel/types.js.map +1 -1
  18. package/build/commonjs/ViewPager/ViewPagerNative.js +45 -17
  19. package/build/commonjs/ViewPager/ViewPagerNative.js.map +1 -1
  20. package/build/commonjs/ViewPager/ViewPagerProps.js.map +1 -1
  21. package/build/commonjs/ViewPager/ViewPagerWeb.js +7 -7
  22. package/build/commonjs/ViewPager/ViewPagerWeb.js.map +1 -1
  23. package/build/module/Carousel/Carousel.js +12 -7
  24. package/build/module/Carousel/Carousel.js.map +1 -1
  25. package/build/module/Carousel/CarouselProps.js.map +1 -1
  26. package/build/module/Carousel/animation/parallaxItemStyleFactory.js +13 -13
  27. package/build/module/Carousel/animation/parallaxItemStyleFactory.js.map +1 -1
  28. package/build/module/Carousel/components/InternalContext.js.map +1 -1
  29. package/build/module/Carousel/components/ItemView.js +4 -2
  30. package/build/module/Carousel/components/ItemView.js.map +1 -1
  31. package/build/module/Carousel/components/RootView.js +22 -4
  32. package/build/module/Carousel/components/RootView.js.map +1 -1
  33. package/build/module/Carousel/components/ScrollViewGesture.js +12 -7
  34. package/build/module/Carousel/components/ScrollViewGesture.js.map +1 -1
  35. package/build/module/Carousel/hooks/useAutoplayController.js +4 -1
  36. package/build/module/Carousel/hooks/useAutoplayController.js.map +1 -1
  37. package/build/module/Carousel/hooks/usePagingAnimation.js +57 -19
  38. package/build/module/Carousel/hooks/usePagingAnimation.js.map +1 -1
  39. package/build/module/Carousel/types.js.map +1 -1
  40. package/build/module/ViewPager/ViewPagerNative.js +45 -17
  41. package/build/module/ViewPager/ViewPagerNative.js.map +1 -1
  42. package/build/module/ViewPager/ViewPagerProps.js.map +1 -1
  43. package/build/module/ViewPager/ViewPagerWeb.js +8 -8
  44. package/build/module/ViewPager/ViewPagerWeb.js.map +1 -1
  45. package/build/typescript/Carousel/CarouselProps.d.ts +4 -3
  46. package/build/typescript/Carousel/animation/parallaxItemStyleFactory.d.ts +5 -5
  47. package/build/typescript/Carousel/components/InternalContext.d.ts +2 -2
  48. package/build/typescript/Carousel/components/ItemView.d.ts +2 -0
  49. package/build/typescript/Carousel/components/RootView.d.ts +4 -4
  50. package/build/typescript/Carousel/components/ScrollViewGesture.d.ts +1 -1
  51. package/build/typescript/Carousel/hooks/usePagingAnimation.d.ts +3 -3
  52. package/build/typescript/Carousel/types.d.ts +25 -3
  53. package/build/typescript/ViewPager/ViewPagerNative.d.ts +1 -1
  54. package/build/typescript/ViewPager/ViewPagerProps.d.ts +1 -1
  55. package/build/typescript/ViewPager/ViewPagerWeb.d.ts +1 -1
  56. package/package.json +2 -2
  57. package/src/Carousel/Carousel.tsx +7 -6
  58. package/src/Carousel/CarouselProps.ts +4 -3
  59. package/src/Carousel/animation/parallaxItemStyleFactory.ts +23 -23
  60. package/src/Carousel/components/InternalContext.ts +2 -2
  61. package/src/Carousel/components/ItemView.tsx +12 -2
  62. package/src/Carousel/components/RootView.tsx +19 -6
  63. package/src/Carousel/components/ScrollViewGesture.tsx +15 -8
  64. package/src/Carousel/hooks/useAutoplayController.ts +4 -1
  65. package/src/Carousel/hooks/usePagingAnimation.ts +70 -23
  66. package/src/Carousel/types.ts +33 -3
  67. package/src/ViewPager/ViewPagerNative.tsx +49 -16
  68. package/src/ViewPager/ViewPagerProps.ts +1 -1
  69. package/src/ViewPager/ViewPagerWeb.tsx +8 -8
@@ -31,17 +31,35 @@ const ViewPager = /*#__PURE__*/(0, _react.forwardRef)(function ViewPager(props,
31
31
  pageForceRerenderKey,
32
32
  scrollEnabled = true,
33
33
  style,
34
- UNSTABLE_sharedIndex
34
+ UNSTABLE_sharedPage
35
35
  } = props;
36
- const fallbackSharedIndex = (0, _reactNativeReanimated.useSharedValue)(initialPage);
37
- const sharedIndex = UNSTABLE_sharedIndex ?? fallbackSharedIndex;
36
+ const fallbackSharedPage = (0, _reactNativeReanimated.useSharedValue)(initialPage);
37
+ const sharedPage = UNSTABLE_sharedPage ?? fallbackSharedPage;
38
+ const desiredPageRef = (0, _react.useRef)(NaN);
38
39
  const pagerRef = (0, _react.useRef)(null);
39
40
  const animationFrameRef = (0, _react.useRef)(NaN);
40
- const setPage = (0, _react.useCallback)(newIndex => {
41
+ const setPage = (0, _react.useCallback)(newPage => {
42
+ if (!Number.isInteger(newPage)) {
43
+ return;
44
+ }
45
+
41
46
  animationFrameRef.current = requestAnimationFrame(() => {
42
47
  var _pagerRef$current;
43
48
 
44
- (_pagerRef$current = pagerRef.current) === null || _pagerRef$current === void 0 ? void 0 : _pagerRef$current.setPage(newIndex);
49
+ if (Number.isFinite(desiredPageRef.current)) {
50
+ if (sharedPage.value === desiredPageRef.current) {
51
+ // end of state machine. clear desired page.
52
+ desiredPageRef.current = NaN;
53
+ return;
54
+ }
55
+
56
+ if (newPage === desiredPageRef.current) {
57
+ return;
58
+ }
59
+ }
60
+
61
+ desiredPageRef.current = newPage;
62
+ (_pagerRef$current = pagerRef.current) === null || _pagerRef$current === void 0 ? void 0 : _pagerRef$current.setPage(newPage);
45
63
  });
46
64
  }, []);
47
65
  (0, _react.useEffect)(() => {
@@ -51,21 +69,31 @@ const ViewPager = /*#__PURE__*/(0, _react.forwardRef)(function ViewPager(props,
51
69
  }
52
70
  };
53
71
  }, []);
54
- (0, _reactNativeReanimated.useAnimatedReaction)(() => sharedIndex.value, result => {
72
+ (0, _reactNativeReanimated.useAnimatedReaction)(() => sharedPage.value, result => {
55
73
  (0, _reactNativeReanimated.runOnJS)(setPage)(result);
56
74
  }, [setPage]);
57
75
  const handlePageSelected = (0, _react.useCallback)(e => {
58
- const currentIndex = sharedIndex.value;
59
- const nextIndex = e.nativeEvent.position;
76
+ if (Number.isFinite(desiredPageRef.current)) {
77
+ // onPageSelected is called from outer controlling mechanism
78
+ // e.g. sharedPage.value is changed, setPage() is called
79
+ // Due to the onPageSelected bug,
80
+ // we don't trust the value from event, (e.nativeEvent.position)
81
+ // other than that trust the value from desiredPageRef.
82
+ const desiredPage = desiredPageRef.current;
60
83
 
61
- if (currentIndex === nextIndex) {
62
- return;
63
- }
64
-
65
- sharedIndex.value = nextIndex;
84
+ if (sharedPage.value === desiredPage) {
85
+ // end of state machine. clear desired page.
86
+ desiredPageRef.current = NaN;
87
+ } else {
88
+ sharedPage.value = desiredPage;
89
+ }
66
90
 
67
- if (onChange) {
68
- onChange(nextIndex);
91
+ onChange === null || onChange === void 0 ? void 0 : onChange(desiredPage);
92
+ } else {
93
+ const trustfulNextPage = e.nativeEvent.position;
94
+ desiredPageRef.current = trustfulNextPage;
95
+ sharedPage.value = trustfulNextPage;
96
+ onChange === null || onChange === void 0 ? void 0 : onChange(trustfulNextPage);
69
97
  }
70
98
  }, [onChange]);
71
99
  (0, _react.useImperativeHandle)(ref, () => ({
@@ -74,7 +102,7 @@ const ViewPager = /*#__PURE__*/(0, _react.forwardRef)(function ViewPager(props,
74
102
  const PageComponent = pageComponent;
75
103
  return /*#__PURE__*/_react.default.createElement(_reactNativePagerView.default, {
76
104
  ref: pagerRef,
77
- initialPage: initialPage,
105
+ initialPage: sharedPage.value,
78
106
  keyboardDismissMode: keyboardDismissMode,
79
107
  onPageSelected: handlePageSelected,
80
108
  pageMargin: 8,
@@ -87,7 +115,7 @@ const ViewPager = /*#__PURE__*/(0, _react.forwardRef)(function ViewPager(props,
87
115
  loading: loading,
88
116
  offscreenPageRerenderLimit: offscreenPageRerenderLimit,
89
117
  rerenderKey: pageForceRerenderKey,
90
- sharedIndex: sharedIndex
118
+ sharedIndex: sharedPage
91
119
  })));
92
120
  });
93
121
  var _default = ViewPager;
@@ -1 +1 @@
1
- {"version":3,"names":["ViewPager","forwardRef","props","ref","children","initialPage","defaultInitialPage","keyboardDismissMode","loading","defaultLoading","offscreenPageRerenderLimit","defaultOffscreenPageRerenderLimit","onChange","pageComponent","defaultPageComponent","pageForceRerenderKey","scrollEnabled","style","UNSTABLE_sharedIndex","fallbackSharedIndex","useSharedValue","sharedIndex","pagerRef","useRef","animationFrameRef","NaN","setPage","useCallback","newIndex","current","requestAnimationFrame","useEffect","cancelAnimationFrame","useAnimatedReaction","value","result","runOnJS","handlePageSelected","e","currentIndex","nextIndex","nativeEvent","position","useImperativeHandle","PageComponent","Children","map","child","index"],"sources":["ViewPagerNative.tsx"],"sourcesContent":["import React, { Children, forwardRef, useCallback, useEffect, useImperativeHandle, useRef } from 'react';\nimport type { ViewPagerOnPageSelectedEvent } from 'react-native-pager-view';\nimport RNViewPager from 'react-native-pager-view';\nimport { runOnJS, useAnimatedReaction, useSharedValue } from 'react-native-reanimated';\nimport type ViewPagerProps from './ViewPagerProps';\nimport type { ViewPagerInstance } from './ViewPagerProps';\nimport { defaultInitialPage, defaultLoading, defaultOffscreenPageRerenderLimit, defaultPageComponent } from './utils';\n\nconst ViewPager = forwardRef<ViewPagerInstance, ViewPagerProps>(function ViewPager(props, ref) {\n const {\n children,\n initialPage = defaultInitialPage,\n keyboardDismissMode = 'on-drag',\n loading = defaultLoading,\n offscreenPageRerenderLimit = defaultOffscreenPageRerenderLimit,\n onChange,\n pageComponent = defaultPageComponent,\n pageForceRerenderKey,\n scrollEnabled = true,\n style,\n UNSTABLE_sharedIndex,\n } = props;\n\n const fallbackSharedIndex = useSharedValue<number>(initialPage);\n\n const sharedIndex = UNSTABLE_sharedIndex ?? fallbackSharedIndex;\n\n const pagerRef = useRef<RNViewPager | null>(null);\n\n const animationFrameRef = useRef<number>(NaN);\n\n const setPage = useCallback((newIndex: number) => {\n animationFrameRef.current = requestAnimationFrame(() => {\n pagerRef.current?.setPage(newIndex);\n });\n }, []);\n\n useEffect(() => {\n return () => {\n if (animationFrameRef.current) {\n cancelAnimationFrame(animationFrameRef.current);\n }\n };\n }, []);\n\n useAnimatedReaction(\n () => sharedIndex.value,\n (result) => {\n runOnJS(setPage)(result);\n },\n [setPage],\n );\n\n const handlePageSelected = useCallback((e: ViewPagerOnPageSelectedEvent) => {\n const currentIndex = sharedIndex.value;\n const nextIndex = e.nativeEvent.position;\n\n if (currentIndex === nextIndex) {\n return;\n }\n\n sharedIndex.value = nextIndex;\n\n if (onChange) {\n onChange(nextIndex);\n }\n }, [onChange]);\n\n useImperativeHandle(\n ref,\n () => ({ setPage }),\n [setPage],\n );\n\n const PageComponent = pageComponent;\n\n return (\n <RNViewPager\n ref={pagerRef}\n initialPage={initialPage}\n keyboardDismissMode={keyboardDismissMode}\n onPageSelected={handlePageSelected}\n pageMargin={8}\n scrollEnabled={scrollEnabled}\n style={style}\n >\n {Children.map(children, (child, index) => (\n <PageComponent\n key={index}\n children={child}\n index={index}\n loading={loading}\n offscreenPageRerenderLimit={offscreenPageRerenderLimit}\n rerenderKey={pageForceRerenderKey}\n sharedIndex={sharedIndex}\n />\n ))}\n </RNViewPager>\n );\n});\n\nexport default ViewPager;\n"],"mappings":";;;;;;;AAAA;;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IAAAV,kBAAA,EAAaW,CAAD,IAAqC;IACxE,MAAMC,YAAY,GAAGlB,WAAW,CAACa,KAAjC;IACA,MAAMM,SAAS,GAAGF,CAAC,CAACG,WAAF,CAAcC,QAAhC;;IAEA,IAAIH,YAAY,KAAKC,SAArB,EAAgC;MAC5B;IACH;;IAEDnB,WAAW,CAACa,KAAZ,GAAoBM,SAApB;;IAEA,IAAI5B,QAAJ,EAAc;MACVA,QAAQ,CAAC4B,SAAD,CAAR;IACH;EACJ,CAb0B,EAaxB,CAAC5B,QAAD,CAbwB,CAA3B;EAeA,IAAA+B,0BAAA,EACIxC,GADJ,EAEI,OAAO;IAAEuB;EAAF,CAAP,CAFJ,EAGI,CAACA,OAAD,CAHJ;EAMA,MAAMkB,aAAa,GAAG/B,aAAtB;EAEA,oBACI,6BAAC,6BAAD;IACI,GAAG,EAAES,QADT;IAEI,WAAW,EAAEjB,WAFjB;IAGI,mBAAmB,EAAEE,mBAHzB;IAII,cAAc,EAAE8B,kBAJpB;IAKI,UAAU,EAAE,CALhB;IAMI,aAAa,EAAErB,aANnB;IAOI,KAAK,EAAEC;EAPX,GASK4B,eAAA,CAASC,GAAT,CAAa1C,QAAb,EAAuB,CAAC2C,KAAD,EAAQC,KAAR,kBACpB,6BAAC,aAAD;IACI,GAAG,EAAEA,KADT;IAEI,QAAQ,EAAED,KAFd;IAGI,KAAK,EAAEC,KAHX;IAII,OAAO,EAAExC,OAJb;IAKI,0BAA0B,EAAEE,0BALhC;IAMI,WAAW,EAAEK,oBANjB;IAOI,WAAW,EAAEM;EAPjB,EADH,CATL,CADJ;AAuBH,CA3FiB,CAAlB;eA6FerB,S"}
1
+ {"version":3,"names":["ViewPager","forwardRef","props","ref","children","initialPage","defaultInitialPage","keyboardDismissMode","loading","defaultLoading","offscreenPageRerenderLimit","defaultOffscreenPageRerenderLimit","onChange","pageComponent","defaultPageComponent","pageForceRerenderKey","scrollEnabled","style","UNSTABLE_sharedPage","fallbackSharedPage","useSharedValue","sharedPage","desiredPageRef","useRef","NaN","pagerRef","animationFrameRef","setPage","useCallback","newPage","Number","isInteger","current","requestAnimationFrame","isFinite","value","useEffect","cancelAnimationFrame","useAnimatedReaction","result","runOnJS","handlePageSelected","e","desiredPage","trustfulNextPage","nativeEvent","position","useImperativeHandle","PageComponent","Children","map","child","index"],"sources":["ViewPagerNative.tsx"],"sourcesContent":["import React, { Children, forwardRef, useCallback, useEffect, useImperativeHandle, useRef } from 'react';\nimport type { ViewPagerOnPageSelectedEvent } from 'react-native-pager-view';\nimport RNViewPager from 'react-native-pager-view';\nimport { runOnJS, useAnimatedReaction, useSharedValue } from 'react-native-reanimated';\nimport type ViewPagerProps from './ViewPagerProps';\nimport type { ViewPagerInstance } from './ViewPagerProps';\nimport { defaultInitialPage, defaultLoading, defaultOffscreenPageRerenderLimit, defaultPageComponent } from './utils';\n\nconst ViewPager = forwardRef<ViewPagerInstance, ViewPagerProps>(function ViewPager(props, ref) {\n const {\n children,\n initialPage = defaultInitialPage,\n keyboardDismissMode = 'on-drag',\n loading = defaultLoading,\n offscreenPageRerenderLimit = defaultOffscreenPageRerenderLimit,\n onChange,\n pageComponent = defaultPageComponent,\n pageForceRerenderKey,\n scrollEnabled = true,\n style,\n UNSTABLE_sharedPage,\n } = props;\n\n const fallbackSharedPage = useSharedValue<number>(initialPage);\n\n const sharedPage = UNSTABLE_sharedPage ?? fallbackSharedPage;\n\n const desiredPageRef = useRef<number>(NaN);\n\n const pagerRef = useRef<RNViewPager | null>(null);\n\n const animationFrameRef = useRef<number>(NaN);\n\n const setPage = useCallback((newPage: number) => {\n if (!Number.isInteger(newPage)) {\n return;\n }\n\n animationFrameRef.current = requestAnimationFrame(() => {\n if (Number.isFinite(desiredPageRef.current)) {\n if (sharedPage.value === desiredPageRef.current) {\n // end of state machine. clear desired page.\n desiredPageRef.current = NaN;\n return;\n }\n\n if (newPage === desiredPageRef.current) {\n return;\n }\n }\n\n desiredPageRef.current = newPage;\n pagerRef.current?.setPage(newPage);\n });\n }, []);\n\n useEffect(() => {\n return () => {\n if (animationFrameRef.current) {\n cancelAnimationFrame(animationFrameRef.current);\n }\n };\n }, []);\n\n useAnimatedReaction(\n () => sharedPage.value,\n (result) => {\n runOnJS(setPage)(result);\n },\n [setPage],\n );\n\n const handlePageSelected = useCallback((e: ViewPagerOnPageSelectedEvent) => {\n if (Number.isFinite(desiredPageRef.current)) {\n // onPageSelected is called from outer controlling mechanism\n // e.g. sharedPage.value is changed, setPage() is called\n // Due to the onPageSelected bug,\n // we don't trust the value from event, (e.nativeEvent.position)\n // other than that trust the value from desiredPageRef.\n\n const desiredPage = desiredPageRef.current;\n\n if (sharedPage.value === desiredPage) {\n // end of state machine. clear desired page.\n desiredPageRef.current = NaN;\n } else {\n sharedPage.value = desiredPage;\n }\n\n onChange?.(desiredPage);\n } else {\n const trustfulNextPage = e.nativeEvent.position;\n\n desiredPageRef.current = trustfulNextPage;\n\n sharedPage.value = trustfulNextPage;\n\n onChange?.(trustfulNextPage);\n }\n }, [onChange]);\n\n useImperativeHandle(\n ref,\n () => ({ setPage }),\n [setPage],\n );\n\n const PageComponent = pageComponent;\n\n return (\n <RNViewPager\n ref={pagerRef}\n initialPage={sharedPage.value}\n keyboardDismissMode={keyboardDismissMode}\n onPageSelected={handlePageSelected}\n pageMargin={8}\n scrollEnabled={scrollEnabled}\n style={style}\n >\n {Children.map(children, (child, index) => (\n <PageComponent\n key={index}\n children={child}\n index={index}\n loading={loading}\n offscreenPageRerenderLimit={offscreenPageRerenderLimit}\n rerenderKey={pageForceRerenderKey}\n sharedIndex={sharedPage}\n />\n ))}\n </RNViewPager>\n );\n});\n\nexport default ViewPager;\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAGA;;;;;;;;AAEA,MAAMA,SAAS,gBAAG,IAAAC,iBAAA,EAA8C,SAASD,SAAT,CAAmBE,KAAnB,EAA0BC,GAA1B,EAA+B;EAC3F,MAAM;IACFC,QADE;IAEFC,WAAW,GAAGC,yBAFZ;IAGFC,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E5B,mBAHzB;IAII,cAAc,EAAEkC,kBAJpB;IAKI,UAAU,EAAE,CALhB;IAMI,aAAa,EAAEzB,aANnB;IAOI,KAAK,EAAEC;EAPX,GASKgC,eAAA,CAASC,GAAT,CAAa9C,QAAb,EAAuB,CAAC+C,KAAD,EAAQC,KAAR,kBACpB,6BAAC,aAAD;IACI,GAAG,EAAEA,KADT;IAEI,QAAQ,EAAED,KAFd;IAGI,KAAK,EAAEC,KAHX;IAII,OAAO,EAAE5C,OAJb;IAKI,0BAA0B,EAAEE,0BALhC;IAMI,WAAW,EAAEK,oBANjB;IAOI,WAAW,EAAEM;EAPjB,EADH,CATL,CADJ;AAuBH,CA5HiB,CAAlB;eA8HerB,S"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["ViewPagerProps.ts"],"sourcesContent":["import type { ComponentType, PropsWithChildren, ReactNode, Ref } from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { SharedValue } from 'react-native-reanimated';\nimport type { ComponentProps } from '@fountain-ui/core';\n\nexport type KeyboardDismissMode = 'none' | 'on-drag';\n\nexport type PageProps = PropsWithChildren<ViewProps> & {\n index: number;\n loading: ViewPagerProps['loading'];\n offscreenPageRerenderLimit: number;\n sharedIndex: SharedValue<number>;\n rerenderKey?: ViewPagerProps['pageForceRerenderKey'];\n};\n\nexport type PageComponent = ComponentType<PageProps>;\n\nexport type Loading = 'lazy' | 'eager';\n\nexport interface ViewPagerInstance {\n /**\n * Function to scroll to a specific page in the ViewPager. Invalid index is ignored.\n * @param index\n */\n setPage: (index: number) => void;\n}\n\nexport default interface ViewPagerProps extends ComponentProps<{\n ref?: Ref<ViewPagerInstance>;\n\n /**\n * Collection of ViewPager components.\n */\n children?: ReactNode;\n\n /**\n * Index of initial page that should be selected.\n * @default 0\n */\n initialPage?: number;\n\n /**\n * Whether to load the page immediately (`eager`) or on an as-needed basis (`lazy`).\n * @default 'lazy'\n */\n loading?: Loading;\n\n /**\n * Mobile only. The number of pages that should be re-rendered to either side of the current page.\n * Changing this value after the component mount has no effect.\n * @default 0\n */\n offscreenPageRerenderLimit?: number;\n\n /**\n * Callback fired when an index is changed.\n */\n onChange?: (newIndex: number) => void,\n\n /**\n * The component used to render the wrapper of the page.\n * @default 'ChildrenMemoizedPage'\n */\n pageComponent?: PageComponent,\n\n /**\n * When this value is changed, page will be rerender.\n */\n pageForceRerenderKey?: any;\n\n /**\n * Mobile only. Should pager view scroll, when scroll enabled.\n * @default true\n */\n scrollEnabled?: boolean;\n\n /**\n * Mobile only. Determines whether the keyboard gets dismissed in response to a drag.\n * @default 'on-drag'\n */\n keyboardDismissMode?: KeyboardDismissMode;\n\n /**\n * Unstable API.\n */\n UNSTABLE_sharedIndex?: SharedValue<number>;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["ViewPagerProps.ts"],"sourcesContent":["import type { ComponentType, PropsWithChildren, ReactNode, Ref } from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { SharedValue } from 'react-native-reanimated';\nimport type { ComponentProps } from '@fountain-ui/core';\n\nexport type KeyboardDismissMode = 'none' | 'on-drag';\n\nexport type PageProps = PropsWithChildren<ViewProps> & {\n index: number;\n loading: ViewPagerProps['loading'];\n offscreenPageRerenderLimit: number;\n sharedIndex: SharedValue<number>;\n rerenderKey?: ViewPagerProps['pageForceRerenderKey'];\n};\n\nexport type PageComponent = ComponentType<PageProps>;\n\nexport type Loading = 'lazy' | 'eager';\n\nexport interface ViewPagerInstance {\n /**\n * Function to scroll to a specific page in the ViewPager. Invalid index is ignored.\n * @param index\n */\n setPage: (index: number) => void;\n}\n\nexport default interface ViewPagerProps extends ComponentProps<{\n ref?: Ref<ViewPagerInstance>;\n\n /**\n * Collection of ViewPager components.\n */\n children?: ReactNode;\n\n /**\n * Index of initial page that should be selected.\n * @default 0\n */\n initialPage?: number;\n\n /**\n * Whether to load the page immediately (`eager`) or on an as-needed basis (`lazy`).\n * @default 'lazy'\n */\n loading?: Loading;\n\n /**\n * Mobile only. The number of pages that should be re-rendered to either side of the current page.\n * Changing this value after the component mount has no effect.\n * @default 0\n */\n offscreenPageRerenderLimit?: number;\n\n /**\n * Callback fired when an index is changed.\n */\n onChange?: (newIndex: number) => void,\n\n /**\n * The component used to render the wrapper of the page.\n * @default 'ChildrenMemoizedPage'\n */\n pageComponent?: PageComponent,\n\n /**\n * When this value is changed, page will be rerender.\n */\n pageForceRerenderKey?: any;\n\n /**\n * Mobile only. Should pager view scroll, when scroll enabled.\n * @default true\n */\n scrollEnabled?: boolean;\n\n /**\n * Mobile only. Determines whether the keyboard gets dismissed in response to a drag.\n * @default 'on-drag'\n */\n keyboardDismissMode?: KeyboardDismissMode;\n\n /**\n * Unstable API.\n */\n UNSTABLE_sharedPage?: SharedValue<number>;\n}> {}\n"],"mappings":""}
@@ -35,13 +35,13 @@ const ViewPager = /*#__PURE__*/(0, _react.forwardRef)(function ViewPager(props,
35
35
  pageComponent = _utils.defaultPageComponent,
36
36
  pageForceRerenderKey,
37
37
  style,
38
- UNSTABLE_sharedIndex
38
+ UNSTABLE_sharedPage
39
39
  } = props;
40
- const fallbackSharedIndex = (0, _reactNativeReanimated.useSharedValue)(initialPage);
41
- const sharedIndex = UNSTABLE_sharedIndex ?? fallbackSharedIndex;
42
- const setPage = (0, _react.useCallback)(newIndex => {
43
- sharedIndex.value = newIndex;
44
- }, [sharedIndex]);
40
+ const fallbackSharedPage = (0, _reactNativeReanimated.useSharedValue)(initialPage);
41
+ const sharedPage = UNSTABLE_sharedPage ?? fallbackSharedPage;
42
+ const setPage = (0, _react.useCallback)(newPage => {
43
+ sharedPage.value = newPage;
44
+ }, [sharedPage]);
45
45
  (0, _react.useImperativeHandle)(ref, () => ({
46
46
  setPage
47
47
  }), [setPage]);
@@ -56,7 +56,7 @@ const ViewPager = /*#__PURE__*/(0, _react.forwardRef)(function ViewPager(props,
56
56
  offscreenPageRerenderLimit: 0 // All offscreen pages will not be re-rendered
57
57
  ,
58
58
  rerenderKey: pageForceRerenderKey,
59
- sharedIndex: sharedIndex
59
+ sharedIndex: sharedPage
60
60
  })));
61
61
  });
62
62
  var _default = ViewPager;
@@ -1 +1 @@
1
- {"version":3,"names":["styles","StyleSheet","create","root","overflow","position","ViewPager","forwardRef","props","ref","children","initialPage","defaultInitialPage","loading","defaultLoading","pageComponent","defaultPageComponent","pageForceRerenderKey","style","UNSTABLE_sharedIndex","fallbackSharedIndex","useSharedValue","sharedIndex","setPage","useCallback","newIndex","value","useImperativeHandle","PageComponent","Children","map","child","index"],"sources":["ViewPagerWeb.tsx"],"sourcesContent":["import React, { Children, forwardRef, useImperativeHandle, useCallback } from 'react';\nimport { View } from 'react-native';\nimport { useSharedValue } from 'react-native-reanimated';\nimport { StyleSheet } from '@fountain-ui/core';\nimport type ViewPagerProps from './ViewPagerProps';\nimport type { ViewPagerInstance } from './ViewPagerProps';\nimport { defaultInitialPage, defaultLoading, defaultPageComponent } from './utils';\n\nconst styles = StyleSheet.create({\n root: {\n // @ts-ignore\n overflow: 'auto',\n position: 'relative',\n },\n});\n\nconst ViewPager = forwardRef<ViewPagerInstance, ViewPagerProps>(function ViewPager(props, ref) {\n const {\n children,\n initialPage = defaultInitialPage,\n loading = defaultLoading,\n pageComponent = defaultPageComponent,\n pageForceRerenderKey,\n style,\n UNSTABLE_sharedIndex,\n } = props;\n\n const fallbackSharedIndex = useSharedValue<number>(initialPage);\n\n const sharedIndex = UNSTABLE_sharedIndex ?? fallbackSharedIndex;\n\n const setPage = useCallback((newIndex: number) => {\n sharedIndex.value = newIndex;\n }, [sharedIndex]);\n\n useImperativeHandle(\n ref,\n () => ({ setPage }),\n [setPage],\n );\n\n const PageComponent = pageComponent;\n\n return (\n <View style={[styles.root, style]}>\n {Children.map(children, (child, index) => (\n <PageComponent\n key={index}\n children={child}\n index={index}\n loading={loading}\n offscreenPageRerenderLimit={0} // All offscreen pages will not be re-rendered\n rerenderKey={pageForceRerenderKey}\n sharedIndex={sharedIndex}\n />\n ))}\n </View>\n );\n});\n\nexport default ViewPager;\n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L,CADJ;AAeH,CA1CiB,CAAlB;eA4CehB,S"}
1
+ {"version":3,"names":["styles","StyleSheet","create","root","overflow","position","ViewPager","forwardRef","props","ref","children","initialPage","defaultInitialPage","loading","defaultLoading","pageComponent","defaultPageComponent","pageForceRerenderKey","style","UNSTABLE_sharedPage","fallbackSharedPage","useSharedValue","sharedPage","setPage","useCallback","newPage","value","useImperativeHandle","PageComponent","Children","map","child","index"],"sources":["ViewPagerWeb.tsx"],"sourcesContent":["import React, { Children, forwardRef, useCallback, useImperativeHandle } from 'react';\nimport { View } from 'react-native';\nimport { useSharedValue } from 'react-native-reanimated';\nimport { StyleSheet } from '@fountain-ui/core';\nimport type ViewPagerProps from './ViewPagerProps';\nimport type { ViewPagerInstance } from './ViewPagerProps';\nimport { defaultInitialPage, defaultLoading, defaultPageComponent } from './utils';\n\nconst styles = StyleSheet.create({\n root: {\n // @ts-ignore\n overflow: 'auto',\n position: 'relative',\n },\n});\n\nconst ViewPager = forwardRef<ViewPagerInstance, ViewPagerProps>(function ViewPager(props, ref) {\n const {\n children,\n initialPage = defaultInitialPage,\n loading = defaultLoading,\n pageComponent = defaultPageComponent,\n pageForceRerenderKey,\n style,\n UNSTABLE_sharedPage,\n } = props;\n\n const fallbackSharedPage = useSharedValue<number>(initialPage);\n\n const sharedPage = UNSTABLE_sharedPage ?? fallbackSharedPage;\n\n const setPage = useCallback((newPage: number) => {\n sharedPage.value = newPage;\n }, [sharedPage]);\n\n useImperativeHandle(\n ref,\n () => ({ setPage }),\n [setPage],\n );\n\n const PageComponent = pageComponent;\n\n return (\n <View style={[styles.root, style]}>\n {Children.map(children, (child, index) => (\n <PageComponent\n key={index}\n children={child}\n index={index}\n loading={loading}\n offscreenPageRerenderLimit={0} // All offscreen pages will not be re-rendered\n rerenderKey={pageForceRerenderKey}\n sharedIndex={sharedPage}\n />\n ))}\n </View>\n );\n});\n\nexport default ViewPager;\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAGA;;;;;;AA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7 @@ const Carousel = /*#__PURE__*/forwardRef(function Carousel(props, ref) {
46
46
  const {
47
47
  finalizeAnimation,
48
48
  globalInterpolation,
49
- startAnimation
49
+ startPagingAnimation
50
50
  } = usePagingAnimation({
51
51
  controlledTx,
52
52
  createScrollAnimation,
@@ -60,7 +60,7 @@ const Carousel = /*#__PURE__*/forwardRef(function Carousel(props, ref) {
60
60
  const autoplayController = useAutoplayController({
61
61
  enabled: autoplay,
62
62
  intervalMillis: autoplayInterval,
63
- startPagingAnimation: startAnimation
63
+ startPagingAnimation
64
64
  });
65
65
  useDimensionChangeReaction({
66
66
  controlledTx,
@@ -68,10 +68,15 @@ const Carousel = /*#__PURE__*/forwardRef(function Carousel(props, ref) {
68
68
  itemWidth
69
69
  });
70
70
  useImperativeHandle(ref, () => ({
71
- next: () => startAnimation('next'),
72
- prev: () => startAnimation('prev'),
73
- getCurrentIndex
74
- }), [startAnimation, getCurrentIndex]);
71
+ getCurrentIndex,
72
+ next: () => startPagingAnimation('directional', {
73
+ direction: 'next'
74
+ }),
75
+ prev: () => startPagingAnimation('directional', {
76
+ direction: 'prev'
77
+ }),
78
+ scrollTo: option => startPagingAnimation('index', option)
79
+ }), [startPagingAnimation, getCurrentIndex]);
75
80
  const contextValue = useMemo(() => ({
76
81
  createItemStyle,
77
82
  data,
@@ -102,7 +107,7 @@ const Carousel = /*#__PURE__*/forwardRef(function Carousel(props, ref) {
102
107
  finalizeAnimation: finalizeAnimation,
103
108
  offsetTx: offsetTx,
104
109
  scrollEnabled: scrollEnabled,
105
- startAnimation: startAnimation
110
+ startPagingAnimation: startPagingAnimation
106
111
  }, /*#__PURE__*/React.createElement(RootView, {
107
112
  data: data,
108
113
  itemHeight: itemHeight,
@@ -1 +1 @@
1
- {"version":3,"names":["React","forwardRef","memo","useImperativeHandle","useMemo","useRef","Animated","ViewabilityTrackerView","useAutoplayController","useDimensionChangeReaction","useIndexController","useItemVisibilityStore","useLoopedData","usePagingAnimation","createDefaultItemStyle","createDefaultScrollAnimation","InternalContext","RootView","ScrollViewGesture","Carousel","props","ref","autoplay","autoplayInterval","createItemStyle","createScrollAnimation","data","originalData","disableSmartAutoplay","initialIndex","itemHeight","itemWidth","loop","onIndexChange","renderItem","scrollEnabled","style","windowSize","initialTx","controlledTx","Value","current","offsetTx","currentIndex","getCurrentIndex","lastIndex","monitorElement","numberOfOriginalData","length","itemVisibilityStore","numberOfData","finalizeAnimation","globalInterpolation","startAnimation","autoplayController","enabled","intervalMillis","startPagingAnimation","next","prev","contextValue","Math","max","visible","resume","pause"],"sources":["Carousel.tsx"],"sourcesContent":["import React, { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';\nimport { Animated } from 'react-native';\nimport ViewabilityTrackerView from '../ViewabilityTrackerView';\nimport type CarouselProps from './CarouselProps';\nimport type { CarouselInstance } from './types';\nimport {\n useAutoplayController,\n useDimensionChangeReaction,\n useIndexController,\n useItemVisibilityStore,\n useLoopedData,\n usePagingAnimation,\n} from './hooks';\nimport { createDefaultItemStyle, createDefaultScrollAnimation } from './animation';\nimport { InternalContext, RootView, ScrollViewGesture } from './components';\n\nconst Carousel = forwardRef<CarouselInstance, CarouselProps>(function Carousel(props, ref) {\n const {\n autoplay = false,\n autoplayInterval = 3000,\n createItemStyle = createDefaultItemStyle,\n createScrollAnimation = createDefaultScrollAnimation,\n data: originalData,\n disableSmartAutoplay = false,\n initialIndex = 0,\n itemHeight,\n itemWidth,\n loop = false,\n onIndexChange,\n renderItem,\n scrollEnabled = true,\n style,\n windowSize = 5,\n } = props;\n\n const data = useLoopedData(originalData, loop);\n\n const initialTx = itemWidth * initialIndex;\n const controlledTx = useRef(new Animated.Value(initialTx)).current;\n const offsetTx = useRef(new Animated.Value(0)).current;\n\n const {\n currentIndex,\n getCurrentIndex,\n lastIndex,\n monitorElement,\n } = useIndexController({\n controlledTx,\n initialIndex,\n itemWidth,\n numberOfOriginalData: originalData.length,\n onIndexChange,\n });\n\n const itemVisibilityStore = useItemVisibilityStore({\n currentIndex,\n numberOfData: data.length,\n windowSize,\n });\n\n const {\n finalizeAnimation,\n globalInterpolation,\n startAnimation,\n } = usePagingAnimation({\n controlledTx,\n createScrollAnimation,\n getCurrentIndex,\n itemWidth,\n lastIndex,\n loop,\n numberOfData: data.length,\n offsetTx,\n });\n\n const autoplayController = useAutoplayController({\n enabled: autoplay,\n intervalMillis: autoplayInterval,\n startPagingAnimation: startAnimation,\n });\n\n useDimensionChangeReaction({\n controlledTx,\n currentIndex,\n itemWidth,\n });\n\n useImperativeHandle(\n ref,\n () => ({\n next: () => startAnimation('next'),\n prev: () => startAnimation('prev'),\n getCurrentIndex,\n }),\n [startAnimation, getCurrentIndex],\n );\n\n const contextValue = useMemo(() => ({\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n }), [\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n ]);\n\n return (\n <InternalContext.Provider value={contextValue}>\n {monitorElement}\n\n <ViewabilityTrackerView\n enabled={autoplay && !disableSmartAutoplay}\n measurementIntervalMillis={Math.max(3000, autoplayInterval)}\n onViewabilityChange={({ visible }) => {\n if (visible) {\n autoplayController.resume();\n } else {\n autoplayController.pause();\n }\n }}\n >\n <ScrollViewGesture\n autoplayController={autoplayController}\n finalizeAnimation={finalizeAnimation}\n offsetTx={offsetTx}\n scrollEnabled={scrollEnabled}\n startAnimation={startAnimation}\n >\n <RootView\n data={data}\n itemHeight={itemHeight}\n originalData={originalData}\n renderItem={renderItem}\n style={style}\n />\n </ScrollViewGesture>\n </ViewabilityTrackerView>\n </InternalContext.Provider>\n );\n});\n\nexport default memo(Carousel);\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,IAA5B,EAAkCC,mBAAlC,EAAuDC,OAAvD,EAAgEC,MAAhE,QAA8E,OAA9E;AACA,SAASC,QAAT,QAAyB,cAAzB;AACA,OAAOC,sBAAP,MAAmC,2B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AD1B;IAEI,yBAAyB,EAAEiC,IAAI,CAACC,GAAL,CAAS,IAAT,EAAevC,gBAAf,CAF/B;IAGI,mBAAmB,EAAE,QAAiB;MAAA,IAAhB;QAAEwC;MAAF,CAAgB;;MAClC,IAAIA,OAAJ,EAAa;QACTT,kBAAkB,CAACU,MAAnB;MACH,CAFD,MAEO;QACHV,kBAAkB,CAACW,KAAnB;MACH;IACJ;EATL,gBAWI,oBAAC,iBAAD;IACI,kBAAkB,EAAEX,kBADxB;IAEI,iBAAiB,EAAEH,iBAFvB;IAGI,QAAQ,EAAET,QAHd;IAII,aAAa,EAAEP,aAJnB;IAKI,cAAc,EAAEkB;EALpB,gBAOI,oBAAC,QAAD;IACI,IAAI,EAAE3B,IADV;IAEI,UAAU,EAAEI,UAFhB;IAGI,YAAY,EAAEH,YAHlB;IAII,UAAU,EAAEO,UAJhB;IAKI,KAAK,EAAEE;EALX,EAPJ,CAXJ,CAHJ,CADJ;AAiCH,CApI0B,CAA3B;AAsIA,4BAAelC,IAAI,CAACiB,QAAD,CAAnB"}
1
+ {"version":3,"names":["React","forwardRef","memo","useImperativeHandle","useMemo","useRef","Animated","ViewabilityTrackerView","useAutoplayController","useDimensionChangeReaction","useIndexController","useItemVisibilityStore","useLoopedData","usePagingAnimation","createDefaultItemStyle","createDefaultScrollAnimation","InternalContext","RootView","ScrollViewGesture","Carousel","props","ref","autoplay","autoplayInterval","createItemStyle","createScrollAnimation","data","originalData","disableSmartAutoplay","initialIndex","itemHeight","itemWidth","loop","onIndexChange","renderItem","scrollEnabled","style","windowSize","initialTx","controlledTx","Value","current","offsetTx","currentIndex","getCurrentIndex","lastIndex","monitorElement","numberOfOriginalData","length","itemVisibilityStore","numberOfData","finalizeAnimation","globalInterpolation","startPagingAnimation","autoplayController","enabled","intervalMillis","next","direction","prev","scrollTo","option","contextValue","Math","max","visible","resume","pause"],"sources":["Carousel.tsx"],"sourcesContent":["import React, { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';\nimport { Animated } from 'react-native';\nimport ViewabilityTrackerView from '../ViewabilityTrackerView';\nimport type CarouselProps from './CarouselProps';\nimport type { CarouselInstance } from './types';\nimport {\n useAutoplayController,\n useDimensionChangeReaction,\n useIndexController,\n useItemVisibilityStore,\n useLoopedData,\n usePagingAnimation,\n} from './hooks';\nimport { createDefaultItemStyle, createDefaultScrollAnimation } from './animation';\nimport { InternalContext, RootView, ScrollViewGesture } from './components';\n\nconst Carousel = forwardRef<CarouselInstance, CarouselProps>(function Carousel(props, ref) {\n const {\n autoplay = false,\n autoplayInterval = 3000,\n createItemStyle = createDefaultItemStyle,\n createScrollAnimation = createDefaultScrollAnimation,\n data: originalData,\n disableSmartAutoplay = false,\n initialIndex = 0,\n itemHeight,\n itemWidth,\n loop = false,\n onIndexChange,\n renderItem,\n scrollEnabled = true,\n style,\n windowSize = 5,\n } = props;\n\n const data = useLoopedData(originalData, loop);\n\n const initialTx = itemWidth * initialIndex;\n const controlledTx = useRef(new Animated.Value(initialTx)).current;\n const offsetTx = useRef(new Animated.Value(0)).current;\n\n const {\n currentIndex,\n getCurrentIndex,\n lastIndex,\n monitorElement,\n } = useIndexController({\n controlledTx,\n initialIndex,\n itemWidth,\n numberOfOriginalData: originalData.length,\n onIndexChange,\n });\n\n const itemVisibilityStore = useItemVisibilityStore({\n currentIndex,\n numberOfData: data.length,\n windowSize,\n });\n\n const {\n finalizeAnimation,\n globalInterpolation,\n startPagingAnimation,\n } = usePagingAnimation({\n controlledTx,\n createScrollAnimation,\n getCurrentIndex,\n itemWidth,\n lastIndex,\n loop,\n numberOfData: data.length,\n offsetTx,\n });\n\n const autoplayController = useAutoplayController({\n enabled: autoplay,\n intervalMillis: autoplayInterval,\n startPagingAnimation,\n });\n\n useDimensionChangeReaction({\n controlledTx,\n currentIndex,\n itemWidth,\n });\n\n useImperativeHandle(\n ref,\n () => ({\n getCurrentIndex,\n next: () => startPagingAnimation('directional', { direction: 'next' }),\n prev: () => startPagingAnimation('directional', { direction: 'prev' }),\n scrollTo: (option) => startPagingAnimation('index', option),\n }),\n [startPagingAnimation, getCurrentIndex],\n );\n\n const contextValue = useMemo(() => ({\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n }), [\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n ]);\n\n return (\n <InternalContext.Provider value={contextValue}>\n {monitorElement}\n\n <ViewabilityTrackerView\n enabled={autoplay && !disableSmartAutoplay}\n measurementIntervalMillis={Math.max(3000, autoplayInterval)}\n onViewabilityChange={({ visible }) => {\n if (visible) {\n autoplayController.resume();\n } else {\n autoplayController.pause();\n }\n }}\n >\n <ScrollViewGesture\n autoplayController={autoplayController}\n finalizeAnimation={finalizeAnimation}\n offsetTx={offsetTx}\n scrollEnabled={scrollEnabled}\n startPagingAnimation={startPagingAnimation}\n >\n <RootView\n data={data}\n itemHeight={itemHeight}\n originalData={originalData}\n renderItem={renderItem}\n style={style}\n />\n </ScrollViewGesture>\n </ViewabilityTrackerView>\n </InternalContext.Provider>\n );\n});\n\nexport default memo(Carousel);\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,IAA5B,EAAkCC,mBAAlC,EAAuDC,OAAvD,EAAgEC,MAAhE,QAA8E,OAA9E;AACA,SAASC,QAAT,QAAyB,cAAzB;AACA,OAAOC,sBAAP,MAAmC,2BAAnC;AAGA,SACIC,qBADJ,EAEIC,0BAFJ,EAGIC,kBAHJ,EAIIC,sBAJJ,EAKIC,aALJ,EAMIC,kBANJ,QAOO,SAPP;AAQA,SAASC,sBAAT,EAAiCC,4BAAjC,QAAqE,aAArE;AACA,SAASC,eAAT,EAA0BC,QAA1B,EAAoCC,iBAApC,QAA6D,cAA7D;AAEA,MAAMC,QAAQ,gBAAGlB,UAAU,CAAkC,SAASkB,QAAT,CAAkBC,KAAlB,EAAyBC,GAAzB,EAA8B;EACvF,MAAM;IACFC,QAAQ,G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;MACH,CAFD,MAEO;QACHZ,kBAAkB,CAACa,KAAnB;MACH;IACJ;EATL,gBAWI,oBAAC,iBAAD;IACI,kBAAkB,EAAEb,kBADxB;IAEI,iBAAiB,EAAEH,iBAFvB;IAGI,QAAQ,EAAET,QAHd;IAII,aAAa,EAAEP,aAJnB;IAKI,oBAAoB,EAAEkB;EAL1B,gBAOI,oBAAC,QAAD;IACI,IAAI,EAAE3B,IADV;IAEI,UAAU,EAAEI,UAFhB;IAGI,YAAY,EAAEH,YAHlB;IAII,UAAU,EAAEO,UAJhB;IAKI,KAAK,EAAEE;EALX,EAPJ,CAXJ,CAHJ,CADJ;AAiCH,CArI0B,CAA3B;AAuIA,4BAAelC,IAAI,CAACiB,QAAD,CAAnB"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["CarouselProps.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\nimport type { CarouselInstance, CreateItemStyle, CreateScrollAnimation, RenderItem } from './types';\n\nexport default interface CarouselProps<ItemT = any> extends ComponentProps<{\n ref?: RefObject<CarouselInstance>;\n\n /**\n * If `true`, enable autoplay.\n * @default false\n */\n autoplay?: boolean;\n\n /**\n * Delay in ms until navigating to the next item.\n * @default 3000\n */\n autoplayInterval?: number;\n\n /**\n * The item style creator function.\n * @default createDefaultItemStyle\n */\n createItemStyle?: CreateItemStyle;\n\n /**\n * The scroll animation creator function.\n * @default createDefaultScrollAnimation\n */\n createScrollAnimation?: CreateScrollAnimation;\n\n /**\n * Data for render items.\n */\n data: ReadonlyArray<ItemT>;\n\n /**\n * If `true`, carousel will detect its own viewability and control autoplay automatically.\n * @default false\n */\n disableSmartAutoplay?: boolean;\n\n /**\n * Index of initial item that should be selected.\n * @default 0\n */\n initialIndex?: number;\n\n /**\n * The item width.\n */\n itemHeight: number;\n\n /**\n * The item width.\n */\n itemWidth: number;\n\n /**\n * Enable infinite loop mode.\n * @default false\n */\n loop?: boolean;\n\n /**\n * Callback fired when an index is changed.\n */\n onIndexChange?: (newIndex: number) => void;\n\n /**\n * Takes an item from data and renders it into the list.\n */\n renderItem: RenderItem<ItemT>;\n\n /**\n * Whether to enable scroll gesture.\n * @default true\n */\n scrollEnabled?: boolean;\n\n /**\n * The maximum number of items that can respond to pan gesture events.\n * Due to the nature of the `active` item, it accepts only odd number. (e.g. 1, 3, 5...)\n * 0 means all items will respond to pan gesture events.\n * @default 5\n */\n windowSize?: number;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["CarouselProps.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\nimport type { CarouselInstance, CreateItemStyle, CreateScrollAnimation, ItemHeight, RenderItem } from './types';\n\nexport default interface CarouselProps<ItemT = any> extends ComponentProps<{\n ref?: RefObject<CarouselInstance>;\n\n /**\n * If `true`, enable autoplay.\n * @default false\n */\n autoplay?: boolean;\n\n /**\n * Delay in ms until navigating to the next item.\n * @default 3000\n */\n autoplayInterval?: number;\n\n /**\n * The item style creator function.\n * @default createDefaultItemStyle\n */\n createItemStyle?: CreateItemStyle;\n\n /**\n * The scroll animation creator function.\n * @default createDefaultScrollAnimation\n */\n createScrollAnimation?: CreateScrollAnimation;\n\n /**\n * Data for render items.\n */\n data: ReadonlyArray<ItemT>;\n\n /**\n * If `true`, carousel will detect its own viewability and control autoplay automatically.\n * @default false\n */\n disableSmartAutoplay?: boolean;\n\n /**\n * Index of initial item that should be selected.\n * @default 0\n */\n initialIndex?: number;\n\n /**\n * The item height.\n * For a performance reason, always consider to provide a number value.\n */\n itemHeight: ItemHeight;\n\n /**\n * The item width.\n */\n itemWidth: number;\n\n /**\n * Enable infinite loop mode.\n * @default false\n */\n loop?: boolean;\n\n /**\n * Callback fired when an index is changed.\n */\n onIndexChange?: (newIndex: number) => void;\n\n /**\n * Takes an item from data and renders it into the list.\n */\n renderItem: RenderItem<ItemT>;\n\n /**\n * Whether to enable scroll gesture.\n * @default true\n */\n scrollEnabled?: boolean;\n\n /**\n * The maximum number of items that can respond to pan gesture events.\n * Due to the nature of the `active` item, it accepts only odd number. (e.g. 1, 3, 5...)\n * 0 means all items will respond to pan gesture events.\n * @default 5\n */\n windowSize?: number;\n}> {}\n"],"mappings":""}
@@ -1,19 +1,19 @@
1
1
  import { itemInterpolationInputRange } from './animationUtils';
2
2
  const defaultParallaxAnimationConfig = {
3
- parallaxActiveItemScale: 0.9,
4
- parallaxActiveItemOpacity: 1,
5
- parallaxAdjacentItemScale: Math.pow(0.9, 2),
6
- parallaxAdjacentItemOpacity: 0.5,
7
- parallaxScrollingOffset: 50
3
+ activeItemScale: 0.9,
4
+ activeItemOpacity: 1,
5
+ adjacentItemScale: Math.pow(0.9, 2),
6
+ adjacentItemOpacity: 0.5,
7
+ scrollingOffset: 50
8
8
  };
9
9
  export default function parallaxItemStyleFactory() {
10
10
  let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultParallaxAnimationConfig;
11
11
  const {
12
- parallaxActiveItemScale,
13
- parallaxActiveItemOpacity,
14
- parallaxAdjacentItemOpacity,
15
- parallaxAdjacentItemScale,
16
- parallaxScrollingOffset
12
+ activeItemOpacity,
13
+ activeItemScale,
14
+ adjacentItemOpacity,
15
+ adjacentItemScale,
16
+ scrollingOffset
17
17
  } = { ...config,
18
18
  ...defaultParallaxAnimationConfig
19
19
  };
@@ -21,7 +21,7 @@ export default function parallaxItemStyleFactory() {
21
21
  const createItemStyle = (itemInterpolation, itemWidth) => {
22
22
  const translate = itemInterpolation.interpolate({
23
23
  inputRange: itemInterpolationInputRange,
24
- outputRange: [-itemWidth + parallaxScrollingOffset, 0, itemWidth - parallaxScrollingOffset]
24
+ outputRange: [-itemWidth + scrollingOffset, 0, itemWidth - scrollingOffset]
25
25
  });
26
26
  const zIndex = itemInterpolation.interpolate({
27
27
  inputRange: itemInterpolationInputRange,
@@ -30,12 +30,12 @@ export default function parallaxItemStyleFactory() {
30
30
  });
31
31
  const scale = itemInterpolation.interpolate({
32
32
  inputRange: itemInterpolationInputRange,
33
- outputRange: [parallaxAdjacentItemScale, parallaxActiveItemScale, parallaxAdjacentItemScale],
33
+ outputRange: [adjacentItemScale, activeItemScale, adjacentItemScale],
34
34
  extrapolate: 'clamp'
35
35
  });
36
36
  const opacity = itemInterpolation.interpolate({
37
37
  inputRange: itemInterpolationInputRange,
38
- outputRange: [parallaxAdjacentItemOpacity, parallaxActiveItemOpacity, parallaxAdjacentItemOpacity],
38
+ outputRange: [adjacentItemOpacity, activeItemOpacity, adjacentItemOpacity],
39
39
  extrapolate: 'clamp'
40
40
  });
41
41
  return {
@@ -1 +1 @@
1
- {"version":3,"names":["itemInterpolationInputRange","defaultParallaxAnimationConfig","parallaxActiveItemScale","parallaxActiveItemOpacity","parallaxAdjacentItemScale","Math","pow","parallaxAdjacentItemOpacity","parallaxScrollingOffset","parallaxItemStyleFactory","config","createItemStyle","itemInterpolation","itemWidth","translate","interpolate","inputRange","outputRange","zIndex","extrapolate","scale","opacity","transform","translateX"],"sources":["parallaxItemStyleFactory.ts"],"sourcesContent":["import type { CreateItemStyle } from '../types';\nimport { itemInterpolationInputRange } from './animationUtils';\n\nexport interface ParallaxAnimationConfig {\n parallaxActiveItemScale?: number;\n parallaxActiveItemOpacity?: number;\n parallaxAdjacentItemScale?: number;\n parallaxAdjacentItemOpacity?: number;\n parallaxScrollingOffset?: number;\n}\n\nconst defaultParallaxAnimationConfig: Required<Readonly<ParallaxAnimationConfig>> = {\n parallaxActiveItemScale: 0.9,\n parallaxActiveItemOpacity: 1,\n parallaxAdjacentItemScale: Math.pow(0.9, 2),\n parallaxAdjacentItemOpacity: 0.5,\n parallaxScrollingOffset: 50,\n};\n\nexport default function parallaxItemStyleFactory(config: ParallaxAnimationConfig = defaultParallaxAnimationConfig) {\n const {\n parallaxActiveItemScale,\n parallaxActiveItemOpacity,\n parallaxAdjacentItemOpacity,\n parallaxAdjacentItemScale,\n parallaxScrollingOffset,\n }: Required<ParallaxAnimationConfig> = {\n ...config,\n ...defaultParallaxAnimationConfig,\n };\n\n const createItemStyle: CreateItemStyle = (itemInterpolation, itemWidth) => {\n const translate = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n -itemWidth + parallaxScrollingOffset,\n 0,\n itemWidth - parallaxScrollingOffset,\n ],\n });\n\n const zIndex = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [0, itemWidth, 0],\n extrapolate: 'clamp',\n });\n\n const scale = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n parallaxAdjacentItemScale,\n parallaxActiveItemScale,\n parallaxAdjacentItemScale,\n ],\n extrapolate: 'clamp',\n });\n\n const opacity = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n parallaxAdjacentItemOpacity,\n parallaxActiveItemOpacity,\n parallaxAdjacentItemOpacity,\n ],\n extrapolate: 'clamp',\n });\n\n return {\n transform: [\n { translateX: translate },\n { scale },\n ],\n zIndex,\n opacity,\n };\n };\n\n return createItemStyle;\n};\n"],"mappings":"AACA,SAASA,2BAAT,QAA4C,kBAA5C;AAUA,MAAMC,8BAA2E,GAAG;EAChFC,uBAAuB,EAAE,GADuD;EAEhFC,yBAAyB,EAAE,CAFqD;EAGhFC,yBAAyB,EAAEC,IAAI,CAACC,GAAL,CAAS,GAAT,EAAc,CAAd,CAHqD;EAIhFC,2BAA2B,EAAE,GAJmD;EAKhFC,uBAAuB,EAAE;AALuD,CAApF;AAQA,eAAe,SAASC,wBAAT,GAAoG;EAAA,IAAlEC,MAAkE,uEAAhCT,8BAAgC;EAC/G,MAAM;IACFC,uBADE;IAEFC,yBAFE;IAGFI,2BAHE;IAIFH,yBAJE;IAKFI;EALE,IAMiC,EACnC,GAAGE,MADgC;IAEnC,GAAGT;EAFgC,CANvC;;EAWA,MAAMU,eAAgC,GAAG,CAACC,iBAAD,EAAoBC,SAApB,KAAkC;IACvE,MAAMC,SAAS,GAAGF,iBAAiB,CAACG,WAAlB,CAA8B;MAC5CC,UAAU,EAAEhB,2BADgC;MAE5CiB,WAAW,EAAE,CACT,CAACJ,SAAD,GAAaL,uBADJ,EAET,CAFS,EAGTK,SAAS,GAAGL,uBAHH;IAF+B,CAA9B,CAAlB;IASA,MAAMU,MAAM,GAAGN,iBAAiB,CAACG,WAAlB,CAA8B;MACzCC,UAAU,EAAEhB,2BAD6B;MAEzCiB,WAAW,EAAE,CAAC,CAAD,EAAIJ,SAAJ,EAAe,CAAf,CAF4B;MAGzCM,WAAW,EAAE;IAH4B,CAA9B,CAAf;IAMA,MAAMC,KAAK,GAAGR,iBAAiB,CAACG,WAAlB,CAA8B;MACxCC,UAAU,EAAEhB,2BAD4B;MAExCiB,WAAW,EAAE,CACTb,yBADS,EAETF,uBAFS,EAGTE,yBAHS,CAF2B;MAOxCe,WAAW,EAAE;IAP2B,CAA9B,CAAd;IAUA,MAAME,OAAO,GAAGT,iBAAiB,CAACG,WAAlB,CAA8B;MAC1CC,UAAU,EAAEhB,2BAD8B;MAE1CiB,WAAW,EAAE,CACTV,2BADS,EAETJ,yBAFS,EAGTI,2BAHS,CAF6B;MAO1CY,WAAW,EAAE;IAP6B,CAA9B,CAAhB;IAUA,OAAO;MACHG,SAAS,EAAE,CACP;QAAEC,UAAU,EAAET;MAAd,CADO,EAEP;QAAEM;MAAF,CAFO,CADR;MAKHF,MALG;MAMHG;IANG,CAAP;EAQH,CA5CD;;EA8CA,OAAOV,eAAP;AACH;AAAA"}
1
+ {"version":3,"names":["itemInterpolationInputRange","defaultParallaxAnimationConfig","activeItemScale","activeItemOpacity","adjacentItemScale","Math","pow","adjacentItemOpacity","scrollingOffset","parallaxItemStyleFactory","config","createItemStyle","itemInterpolation","itemWidth","translate","interpolate","inputRange","outputRange","zIndex","extrapolate","scale","opacity","transform","translateX"],"sources":["parallaxItemStyleFactory.ts"],"sourcesContent":["import type { CreateItemStyle } from '../types';\nimport { itemInterpolationInputRange } from './animationUtils';\n\nexport interface ParallaxAnimationConfig {\n activeItemScale?: number;\n activeItemOpacity?: number;\n adjacentItemScale?: number;\n adjacentItemOpacity?: number;\n scrollingOffset?: number;\n}\n\nconst defaultParallaxAnimationConfig: Required<Readonly<ParallaxAnimationConfig>> = {\n activeItemScale: 0.9,\n activeItemOpacity: 1,\n adjacentItemScale: Math.pow(0.9, 2),\n adjacentItemOpacity: 0.5,\n scrollingOffset: 50,\n};\n\nexport default function parallaxItemStyleFactory(config: ParallaxAnimationConfig = defaultParallaxAnimationConfig) {\n const {\n activeItemOpacity,\n activeItemScale,\n adjacentItemOpacity,\n adjacentItemScale,\n scrollingOffset,\n }: Required<ParallaxAnimationConfig> = {\n ...config,\n ...defaultParallaxAnimationConfig,\n };\n\n const createItemStyle: CreateItemStyle = (itemInterpolation, itemWidth) => {\n const translate = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n -itemWidth + scrollingOffset,\n 0,\n itemWidth - scrollingOffset,\n ],\n });\n\n const zIndex = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [0, itemWidth, 0],\n extrapolate: 'clamp',\n });\n\n const scale = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n adjacentItemScale,\n activeItemScale,\n adjacentItemScale,\n ],\n extrapolate: 'clamp',\n });\n\n const opacity = itemInterpolation.interpolate({\n inputRange: itemInterpolationInputRange,\n outputRange: [\n adjacentItemOpacity,\n activeItemOpacity,\n adjacentItemOpacity,\n ],\n extrapolate: 'clamp',\n });\n\n return {\n transform: [\n { translateX: translate },\n { scale },\n ],\n zIndex,\n opacity,\n };\n };\n\n return createItemStyle;\n};\n"],"mappings":"AACA,SAASA,2BAAT,QAA4C,kBAA5C;AAUA,MAAMC,8BAA2E,GAAG;EAChFC,eAAe,EAAE,GAD+D;EAEhFC,iBAAiB,EAAE,CAF6D;EAGhFC,iBAAiB,EAAEC,IAAI,CAACC,GAAL,CAAS,GAAT,EAAc,CAAd,CAH6D;EAIhFC,mBAAm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A5CD;;EA8CA,OAAOV,eAAP;AACH;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":["createContext","Animated","mockItemVisibilityStore","dispatch","subscribe","removeAllListeners","initialValue","createItemStyle","data","globalInterpolation","add","Value","itemHeight","itemWidth","itemVisibilityStore","loop","InternalContext"],"sources":["InternalContext.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { Animated } from 'react-native';\nimport type { CreateItemStyle, ItemVisibilityStore } from '../types';\n\nexport interface InternalContextValue<ItemT> {\n createItemStyle: CreateItemStyle;\n data: ReadonlyArray<ItemT>;\n globalInterpolation: Animated.AnimatedInterpolation;\n itemHeight: number;\n itemWidth: number;\n itemVisibilityStore: ItemVisibilityStore;\n loop: boolean;\n}\n\nconst mockItemVisibilityStore: ItemVisibilityStore = {\n dispatch: () => void 0,\n subscribe: () => () => void 0,\n removeAllListeners: () => void 0,\n};\n\nconst initialValue: Readonly<InternalContextValue<any>> = {\n createItemStyle: () => ({}),\n data: [],\n globalInterpolation: Animated.add(new Animated.Value(0), 0),\n itemHeight: 0,\n itemWidth: 0,\n itemVisibilityStore: mockItemVisibilityStore,\n loop: false,\n};\n\nconst InternalContext = createContext<InternalContextValue<any>>(initialValue);\n\nexport default InternalContext;\n"],"mappings":"AAAA,SAASA,aAAT,QAA8B,OAA9B;AACA,SAASC,QAAT,QAAyB,cAAzB;AAaA,MAAMC,uBAA4C,GAAG;EACjDC,QAAQ,EAAE,MAAM,KAAK,CAD4B;EAEjDC,SAAS,EAAE,MAAM,MAAM,KAAK,CAFqB;EAGjDC,kBAAkB,EAAE,MAAM,KAAK;AAHkB,CAArD;AAMA,MAAMC,YAAiD,GAAG;EACtDC,eAAe,EAAE,OAAO,EAAP,CADqC;EAEtDC,IAAI,EAAE,EAFgD;EAGtDC,mBAAmB,EAAER,QAAQ,CAACS,GAAT,CAAa,IAAIT,QAAQ,CAACU,KAAb,CAAmB,CAAnB,CAAb,EAAoC,CAApC,CAHiC;EAItDC,UAAU,EAAE,CAJ0C;EAKtDC,SAAS,EAAE,CAL2C;EAMtDC,mBAAmB,EAAEZ,uBANiC;EAOtDa,IAAI,EAAE;AAPgD,CAA1D;AAUA,MAAMC,eAAe,gBAAGhB,aAAa,CAA4BM,YAA5B,CAArC;AAEA,eAAeU,eAAf"}
1
+ {"version":3,"names":["createContext","Animated","mockItemVisibilityStore","dispatch","subscribe","removeAllListeners","initialValue","createItemStyle","data","globalInterpolation","add","Value","itemHeight","itemWidth","itemVisibilityStore","loop","InternalContext"],"sources":["InternalContext.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { Animated } from 'react-native';\nimport type { CreateItemStyle, ItemHeight, ItemVisibilityStore } from '../types';\n\nexport interface InternalContextValue<ItemT> {\n createItemStyle: CreateItemStyle;\n data: ReadonlyArray<ItemT>;\n globalInterpolation: Animated.AnimatedInterpolation;\n itemHeight: ItemHeight;\n itemWidth: number;\n itemVisibilityStore: ItemVisibilityStore;\n loop: boolean;\n}\n\nconst mockItemVisibilityStore: ItemVisibilityStore = {\n dispatch: () => void 0,\n subscribe: () => () => void 0,\n removeAllListeners: () => void 0,\n};\n\nconst initialValue: Readonly<InternalContextValue<any>> = {\n createItemStyle: () => ({}),\n data: [],\n globalInterpolation: Animated.add(new Animated.Value(0), 0),\n itemHeight: 0,\n itemWidth: 0,\n itemVisibilityStore: mockItemVisibilityStore,\n loop: false,\n};\n\nconst InternalContext = createContext<InternalContextValue<any>>(initialValue);\n\nexport default InternalContext;\n"],"mappings":"AAAA,SAASA,aAAT,QAA8B,OAA9B;AACA,SAASC,QAAT,QAAyB,cAAzB;AAaA,MAAMC,uBAA4C,GAAG;EACjDC,QAAQ,EAAE,MAAM,KAAK,CAD4B;EAEjDC,SAAS,EAAE,MAAM,MAAM,KAAK,CAFqB;EAGjDC,kBAAkB,EAAE,MAAM,KAAK;AAHkB,CAArD;AAMA,MAAMC,YAAiD,GAAG;EACtDC,eAAe,EAAE,OAAO,EAAP,CADqC;EAEtDC,IAAI,EAAE,EAFgD;EAGtDC,mBAAmB,EAAER,QAAQ,CAACS,GAAT,CAAa,IAAIT,QAAQ,CAACU,KAAb,CAAmB,CAAnB,CAAb,EAAoC,CAApC,CAHiC;EAItDC,UAAU,EAAE,CAJ0C;EAKtDC,SAAS,EAAE,CAL2C;EAMtDC,mBAAmB,EAAEZ,uBANiC;EAOtDa,IAAI,EAAE;AAPgD,CAA1D;AAUA,MAAMC,eAAe,gBAAGhB,aAAa,CAA4BM,YAA5B,CAArC;AAEA,eAAeU,eAAf"}
@@ -6,7 +6,8 @@ import InternalContext from './InternalContext';
6
6
  export default function ItemView(props) {
7
7
  const {
8
8
  children,
9
- index
9
+ index,
10
+ onLayout
10
11
  } = props;
11
12
  const {
12
13
  createItemStyle,
@@ -28,9 +29,10 @@ export default function ItemView(props) {
28
29
  }, [itemVisibilityStore]);
29
30
  return /*#__PURE__*/React.createElement(Animated.View, {
30
31
  children: visible ? children(interpolation) : null,
32
+ onLayout: onLayout,
31
33
  style: [{
32
34
  width: itemWidth,
33
- height: itemHeight
35
+ height: itemHeight !== 'auto' ? itemHeight : undefined
34
36
  }, styles.absolute, // @ts-ignore
35
37
  itemStyle]
36
38
  });
@@ -1 +1 @@
1
- {"version":3,"names":["React","useContext","useEffect","useMemo","useState","Animated","StyleSheet","useItemInterpolation","InternalContext","ItemView","props","children","index","createItemStyle","itemHeight","itemWidth","itemVisibilityStore","visible","setVisible","interpolation","itemStyle","subscribe","ranges","nextVisible","some","from","to","width","height","styles","absolute","create","position"],"sources":["ItemView.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useMemo, useState } from 'react';\nimport { Animated } from 'react-native';\nimport { StyleSheet } from '@fountain-ui/core';\nimport { useItemInterpolation } from '../hooks';\nimport InternalContext from './InternalContext';\n\nexport interface ItemViewProps {\n children: (interpolation: Animated.AnimatedInterpolation) => ReactElement | null;\n index: number;\n}\n\nexport default function ItemView(props: ItemViewProps) {\n const { children, index } = props;\n\n const {\n createItemStyle,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n } = useContext(InternalContext);\n\n const [visible, setVisible] = useState(false);\n\n const interpolation = useItemInterpolation(index);\n\n const itemStyle = useMemo(\n () => createItemStyle(interpolation, itemWidth),\n [createItemStyle, interpolation],\n );\n\n useEffect(() => {\n return itemVisibilityStore.subscribe(ranges => {\n const nextVisible = ranges.some(([from, to]) => index >= from && index <= to);\n setVisible(nextVisible);\n });\n }, [itemVisibilityStore]);\n\n return (\n <Animated.View\n children={visible ? children(interpolation) : null}\n style={[\n { width: itemWidth, height: itemHeight },\n styles.absolute,\n // @ts-ignore\n itemStyle,\n ]}\n />\n );\n};\n\nconst styles = StyleSheet.create({\n absolute: {\n position: 'absolute',\n },\n});\n"],"mappings":"AACA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,SAA5B,EAAuCC,OAAvC,EAAgDC,QAAhD,QAAgE,OAAhE;AACA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,UAAT,QAA2B,mBAA3B;AACA,SAASC,oBAAT,QAAqC,UAArC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AAOA,eAAe,SAASC,QAAT,CAAkBC,KAAlB,EAAwC;EACnD,MAAM;IAAEC,QAAF;IAAYC;EAAZ,IAAsBF,KAA5B;EAEA,MAAM;IACFG,eADE;IAEFC,UAFE;IAGFC,SAHE;IAIFC;EAJE,IAKFf,UAAU,CAACO,eAAD,CALd;EAOA,MAAM,CAACS,OAAD,EAAUC,UAAV,IAAwBd,QAAQ,CAAC,KAAD,CAAtC;EAEA,MAAMe,aAAa,GAAGZ,oBAAoB,CAACK,KAAD,CAA1C;EAEA,MAAMQ,SAAS,GAAGjB,OAAO,CACrB,MAAMU,eAAe,CAACM,aAAD,EAAgBJ,SAAhB,CADA,EAErB,CAACF,eAAD,EAAkBM,aAAlB,CAFqB,CAAzB;EAKAjB,SAAS,CAAC,MAAM;IACZ,OAAOc,mBAAmB,CAACK,SAApB,CAA8BC,MAAM,IAAI;MAC3C,MAAMC,WAAW,GAAGD,MAAM,CAACE,IAAP,CAAY;QAAA,IAAC,CAACC,IAAD,EAAOC,EAAP,CAAD;QAAA,OAAgBd,KAAK,IAAIa,IAAT,IAAiBb,KAAK,IAAIc,EAA1C;MAAA,CAAZ,CAApB;MACAR,UAAU,CAACK,WAAD,CAAV;IACH,CAHM,CAAP;EAIH,CALQ,EAKN,CAACP,mBAAD,CALM,CAAT;EAOA,oBACI,oBAAC,QAAD,CAAU,IAAV;IACI,QAAQ,EAAEC,OAAO,GAAGN,QAAQ,CAACQ,aAAD,CAAX,GAA6B,IADlD;IAEI,KAAK,EAAE,CACH;MAAEQ,KAAK,EAAEZ,SAAT;MAAoBa,MAAM,EAAEd;IAA5B,CADG,EAEHe,MAAM,CAACC,QAFJ,EAGH;IACAV,SAJG;EAFX,EADJ;AAWH;AAAA;AAED,MAAMS,MAAM,GAAGvB,UAAU,CAACyB,MAAX,CAAkB;EAC7BD,QAAQ,EAAE;IACNE,QAAQ,EAAE;EADJ;AADmB,CAAlB,CAAf"}
1
+ {"version":3,"names":["React","useContext","useEffect","useMemo","useState","Animated","StyleSheet","useItemInterpolation","InternalContext","ItemView","props","children","index","onLayout","createItemStyle","itemHeight","itemWidth","itemVisibilityStore","visible","setVisible","interpolation","itemStyle","subscribe","ranges","nextVisible","some","from","to","width","height","undefined","styles","absolute","create","position"],"sources":["ItemView.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React, { useContext, useEffect, useMemo, useState } from 'react';\nimport type { ViewProps } from 'react-native';\nimport { Animated } from 'react-native';\nimport { StyleSheet } from '@fountain-ui/core';\nimport { useItemInterpolation } from '../hooks';\nimport InternalContext from './InternalContext';\n\nexport interface ItemViewProps {\n children: (interpolation: Animated.AnimatedInterpolation) => ReactElement | null;\n index: number;\n onLayout?: ViewProps['onLayout'];\n}\n\nexport default function ItemView(props: ItemViewProps) {\n const {\n children,\n index,\n onLayout,\n } = props;\n\n const {\n createItemStyle,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n } = useContext(InternalContext);\n\n const [visible, setVisible] = useState(false);\n\n const interpolation = useItemInterpolation(index);\n\n const itemStyle = useMemo(\n () => createItemStyle(interpolation, itemWidth),\n [createItemStyle, interpolation],\n );\n\n useEffect(() => {\n return itemVisibilityStore.subscribe(ranges => {\n const nextVisible = ranges.some(([from, to]) => index >= from && index <= to);\n setVisible(nextVisible);\n });\n }, [itemVisibilityStore]);\n\n return (\n <Animated.View\n children={visible ? children(interpolation) : null}\n onLayout={onLayout}\n style={[\n {\n width: itemWidth,\n height: itemHeight !== 'auto' ? itemHeight : undefined,\n },\n styles.absolute,\n // @ts-ignore\n itemStyle,\n ]}\n />\n );\n};\n\nconst styles = StyleSheet.create({\n absolute: {\n position: 'absolute',\n },\n});\n"],"mappings":"AACA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,SAA5B,EAAuCC,OAAvC,EAAgDC,QAAhD,QAAgE,OAAhE;AAEA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,UAAT,QAA2B,mBAA3B;AACA,SAASC,oBAAT,QAAqC,UAArC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AAQA,eAAe,SAASC,QAAT,CAAkBC,KAAlB,EAAwC;EACnD,MAAM;IACFC,QADE;IAEFC,KAFE;IAGFC;EAHE,IAIFH,KAJJ;EAMA,MAAM;IACFI,eADE;IAEFC,UAFE;IAGFC,SAHE;IAIFC;EAJE,IAKFhB,UAAU,CAACO,eAAD,CALd;EAOA,MAAM,CAACU,OAAD,EAAUC,UAAV,IAAwBf,QAAQ,CAAC,KAAD,CAAtC;EAEA,MAAMgB,aAAa,GAAGb,oBAAoB,CAACK,KAAD,CAA1C;EAEA,MAAMS,SAAS,GAAGlB,OAAO,CACrB,MAAMW,eAAe,CAACM,aAAD,EAAgBJ,SAAhB,CADA,EAErB,CAACF,eAAD,EAAkBM,aAAlB,CAFqB,CAAzB;EAKAlB,SAAS,CAAC,MAAM;IACZ,OAAOe,mBAAmB,CAACK,SAApB,CAA8BC,MAAM,IAAI;MAC3C,MAAMC,WAAW,GAAGD,MAAM,CAACE,IAAP,CAAY;QAAA,IAAC,CAACC,IAAD,EAAOC,EAAP,CAAD;QAAA,OAAgBf,KAAK,IAAIc,IAAT,IAAiBd,KAAK,IAAIe,EAA1C;MAAA,CAAZ,CAApB;MACAR,UAAU,CAACK,WAAD,CAAV;IACH,CAHM,CAAP;EAIH,CALQ,EAKN,CAACP,mBAAD,CALM,CAAT;EAOA,oBACI,oBAAC,QAAD,CAAU,IAAV;IACI,QAAQ,EAAEC,OAAO,GAAGP,QAAQ,CAACS,aAAD,CAAX,GAA6B,IADlD;IAEI,QAAQ,EAAEP,QAFd;IAGI,KAAK,EAAE,CACH;MACIe,KAAK,EAAEZ,SADX;MAEIa,MAAM,EAAEd,UAAU,KAAK,MAAf,GAAwBA,UAAxB,GAAqCe;IAFjD,CADG,EAKHC,MAAM,CAACC,QALJ,EAMH;IACAX,SAPG;EAHX,EADJ;AAeH;AAAA;AAED,MAAMU,MAAM,GAAGzB,UAAU,CAAC2B,MAAX,CAAkB;EAC7BD,QAAQ,EAAE;IACNE,QAAQ,EAAE;EADJ;AADmB,CAAlB,CAAf"}
@@ -1,6 +1,6 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
- import React, { memo, forwardRef } from 'react';
3
+ import React, { forwardRef, memo, useState } from 'react';
4
4
  import { Animated } from 'react-native';
5
5
  import { StyleSheet } from '@fountain-ui/core';
6
6
  import ItemView from './ItemView';
@@ -11,7 +11,8 @@ const styles = StyleSheet.create({
11
11
  },
12
12
  horizontal: {
13
13
  flexDirection: 'row',
14
- overflow: 'hidden'
14
+ overflowX: 'hidden',
15
+ overflowY: 'visible'
15
16
  }
16
17
  });
17
18
  const RootView = /*#__PURE__*/forwardRef(function RootView(props, ref) {
@@ -23,10 +24,27 @@ const RootView = /*#__PURE__*/forwardRef(function RootView(props, ref) {
23
24
  style,
24
25
  ...otherProps
25
26
  } = props;
27
+ const [maxHeightOfRenderedItems, setMaxHeightOfRenderedItems] = useState(0);
28
+
29
+ const handleItemLayout = e => {
30
+ const {
31
+ nativeEvent: {
32
+ layout: {
33
+ height
34
+ }
35
+ }
36
+ } = e;
37
+ const heightInt = Math.round(height);
38
+
39
+ if (heightInt > maxHeightOfRenderedItems) {
40
+ setMaxHeightOfRenderedItems(heightInt);
41
+ }
42
+ };
26
43
 
27
44
  const renderItemView = (item, index) => /*#__PURE__*/React.createElement(ItemView, {
28
45
  key: index,
29
- index: index
46
+ index: index,
47
+ onLayout: itemHeight === 'auto' ? handleItemLayout : undefined
30
48
  }, interpolation => renderItem({
31
49
  item,
32
50
  index: index % originalData.length,
@@ -34,7 +52,7 @@ const RootView = /*#__PURE__*/forwardRef(function RootView(props, ref) {
34
52
  }));
35
53
 
36
54
  const viewStyles = [styles.root, styles.horizontal, {
37
- height: itemHeight
55
+ height: itemHeight === 'auto' ? maxHeightOfRenderedItems : itemHeight
38
56
  }, style];
39
57
  return /*#__PURE__*/React.createElement(Animated.View, _extends({
40
58
  ref: ref
@@ -1 +1 @@
1
- {"version":3,"names":["React","memo","forwardRef","Animated","StyleSheet","ItemView","styles","create","root","width","justifyContent","horizontal","flexDirection","overflow","RootView","props","ref","data","itemHeight","originalData","renderItem","style","otherProps","renderItemView","item","index","interpolation","length","viewStyles","height","map"],"sources":["RootView.tsx"],"sourcesContent":["import React, { memo, ReactElement, forwardRef } from 'react';\nimport type { ViewProps, View } from 'react-native';\nimport { Animated } from 'react-native';\nimport { StyleSheet } from '@fountain-ui/core';\nimport type { RenderItem } from '../types';\nimport ItemView from './ItemView';\n\nconst styles = StyleSheet.create({\n root: {\n width: '100%',\n justifyContent: 'center',\n },\n horizontal: {\n flexDirection: 'row',\n overflow: 'hidden',\n },\n});\n\nexport type RootViewProps<ItemT> = ViewProps & {\n data: ReadonlyArray<ItemT>;\n itemHeight: number;\n originalData: ReadonlyArray<ItemT>;\n renderItem: RenderItem<ItemT>;\n};\n\nconst RootView = forwardRef<View, RootViewProps<any>>(function RootView(props, ref) {\n const {\n data,\n itemHeight,\n originalData,\n renderItem,\n style,\n ...otherProps\n } = props;\n\n const renderItemView = (item: any, index: number): ReactElement => (\n <ItemView\n key={index}\n index={index}\n >\n {(interpolation) => renderItem({\n item,\n index: index % originalData.length,\n interpolation,\n })}\n </ItemView>\n );\n\n const viewStyles = [\n styles.root,\n styles.horizontal,\n { height: itemHeight },\n style,\n ];\n\n return (\n <Animated.View\n ref={ref}\n {...otherProps}\n children={data.map(renderItemView)}\n style={viewStyles}\n />\n );\n});\n\nexport default memo(RootView);\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,IAAhB,EAAoCC,UAApC,QAAsD,OAAtD;AAEA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,UAAT,QAA2B,mBAA3B;AAEA,OAAOC,QAAP,MAAqB,YAArB;AAEA,MAAMC,MAAM,GAAGF,UAAU,CAACG,MAAX,CAAkB;EAC7BC,IAAI,EAAE;IACFC,KAAK,EAAE,MADL;IAEFC,cAAc,EAAE;EAFd,CADuB;EAK7BC,UAAU,EAAE;IACRC,aAAa,EAAE,KADP;IAERC,QAAQ,EAAE;EAFF;AALiB,CAAlB,CAAf;AAkBA,MAAMC,QAAQ,gBAAGZ,UAAU,CAA2B,SAASY,QAAT,CAAkBC,KAAlB,EAAyBC,GAAzB,EAA8B;EAChF,MAAM;IACFC,IADE;IAEFC,UAFE;IAGFC,YAHE;IAIFC,UAJE;IAKFC,KALE;IAMF,GAAGC;EAND,IAOFP,KAPJ;;EASA,MAAMQ,cAAc,GAAG,CAACC,IAAD,EAAYC,KAAZ,kBACnB,oBAAC,QAAD;IACI,GAAG,EAAEA,KADT;IAEI,KAAK,EAAEA;EAFX,GAIMC,aAAD,IAAmBN,UAAU,CAAC;IAC3BI,IAD2B;IAE3BC,KAAK,EAAEA,KAAK,GAAGN,YAAY,CAACQ,MAFD;IAG3BD;EAH2B,CAAD,CAJlC,CADJ;;EAaA,MAAME,UAAU,GAAG,CACftB,MAAM,CAACE,IADQ,EAEfF,MAAM,CAACK,UAFQ,EAGf;IAAEkB,MAAM,EAAEX;EAAV,CAHe,EAIfG,KAJe,CAAnB;EAOA,oBACI,oBAAC,QAAD,CAAU,IAAV;IACI,GAAG,EAAEL;EADT,GAEQM,UAFR;IAGI,QAAQ,EAAEL,IAAI,CAACa,GAAL,CAASP,cAAT,CAHd;IAII,KAAK,EAAEK;EAJX,GADJ;AAQH,CAtC0B,CAA3B;AAwCA,4BAAe3B,IAAI,CAACa,QAAD,CAAnB"}
1
+ {"version":3,"names":["React","forwardRef","memo","useState","Animated","StyleSheet","ItemView","styles","create","root","width","justifyContent","horizontal","flexDirection","overflowX","overflowY","RootView","props","ref","data","itemHeight","originalData","renderItem","style","otherProps","maxHeightOfRenderedItems","setMaxHeightOfRenderedItems","handleItemLayout","e","nativeEvent","layout","height","heightInt","Math","round","renderItemView","item","index","undefined","interpolation","length","viewStyles","map"],"sources":["RootView.tsx"],"sourcesContent":["import React, { forwardRef, memo, ReactElement, useState } from 'react';\nimport type { View, ViewProps, LayoutChangeEvent } from 'react-native';\nimport { Animated } from 'react-native';\nimport { StyleSheet } from '@fountain-ui/core';\nimport type { ItemHeight, RenderItem } from '../types';\nimport ItemView from './ItemView';\n\nconst styles = StyleSheet.create({\n root: {\n width: '100%',\n justifyContent: 'center',\n },\n horizontal: {\n flexDirection: 'row',\n overflowX: 'hidden',\n overflowY: 'visible',\n },\n});\n\nexport type RootViewProps<ItemT> = ViewProps & {\n data: ReadonlyArray<ItemT>;\n itemHeight: ItemHeight;\n originalData: ReadonlyArray<ItemT>;\n renderItem: RenderItem<ItemT>;\n};\n\nconst RootView = forwardRef<View, RootViewProps<any>>(function RootView(props, ref) {\n const {\n data,\n itemHeight,\n originalData,\n renderItem,\n style,\n ...otherProps\n } = props;\n\n const [maxHeightOfRenderedItems, setMaxHeightOfRenderedItems] = useState(0);\n\n const handleItemLayout = (e: LayoutChangeEvent) => {\n const { nativeEvent: { layout: { height } } } = e;\n\n const heightInt = Math.round(height);\n if (heightInt > maxHeightOfRenderedItems) {\n setMaxHeightOfRenderedItems(heightInt);\n }\n };\n\n const renderItemView = (item: any, index: number): ReactElement => (\n <ItemView\n key={index}\n index={index}\n onLayout={itemHeight === 'auto' ? handleItemLayout : undefined}\n >\n {(interpolation) => renderItem({\n item,\n index: index % originalData.length,\n interpolation,\n })}\n </ItemView>\n );\n\n const viewStyles = [\n styles.root,\n styles.horizontal,\n { height: itemHeight === 'auto' ? maxHeightOfRenderedItems : itemHeight },\n style,\n ];\n\n return (\n <Animated.View\n ref={ref}\n {...otherProps}\n children={data.map(renderItemView)}\n style={viewStyles}\n />\n );\n});\n\nexport default memo(RootView);\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,IAA5B,EAAgDC,QAAhD,QAAgE,OAAhE;AAEA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,UAAT,QAA2B,mBAA3B;AAEA,OAAOC,QAAP,MAAqB,YAArB;AAEA,MAAMC,MAAM,GAAGF,UAAU,CAACG,MAAX,CAAkB;EAC7BC,IAAI,EAAE;IACFC,KAAK,EAAE,MADL;IAEFC,cAAc,EAAE;EAFd,CADuB;EAK7BC,UAAU,EAAE;IACRC,aAAa,EAAE,KADP;IAERC,SAAS,EAAE,QAFH;IAGRC,SAAS,EAAE;EAHH;AALiB,CAAlB,CAAf;AAmBA,MAAMC,QAAQ,gBAAGf,UAAU,CAA2B,SAASe,QAAT,CAAkBC,KAAlB,EAAyBC,GAAzB,EAA8B;EAChF,MAAM;IACFC,IADE;IAEFC,UAFE;IAGFC,YAHE;IAIFC,UAJE;IAKFC,KALE;IAMF,GAAGC;EAND,IAOFP,KAPJ;EASA,MAAM,CAACQ,wBAAD,EAA2BC,2BAA3B,IAA0DvB,QAAQ,CAAC,CAAD,CAAxE;;EAEA,MAAMwB,gBAAgB,GAAIC,CAAD,IAA0B;IAC/C,MAAM;MAAEC,WAAW,EAAE;QAAEC,MAAM,EAAE;UAAEC;QAAF;MAAV;IAAf,IAA0CH,CAAhD;IAEA,MAAMI,SAAS,GAAGC,IAAI,CAACC,KAAL,CAAWH,MAAX,CAAlB;;IACA,IAAIC,SAAS,GAAGP,wBAAhB,EAA0C;MACtCC,2BAA2B,CAACM,SAAD,CAA3B;IACH;EACJ,CAPD;;EASA,MAAMG,cAAc,GAAG,CAACC,IAAD,EAAYC,KAAZ,kBACnB,oBAAC,QAAD;IACI,GAAG,EAAEA,KADT;IAEI,KAAK,EAAEA,KAFX;IAGI,QAAQ,EAAEjB,UAAU,KAAK,MAAf,GAAwBO,gBAAxB,GAA2CW;EAHzD,GAKMC,aAAD,IAAmBjB,UAAU,CAAC;IAC3Bc,IAD2B;IAE3BC,KAAK,EAAEA,KAAK,GAAGhB,YAAY,CAACmB,MAFD;IAG3BD;EAH2B,CAAD,CALlC,CADJ;;EAcA,MAAME,UAAU,GAAG,CACflC,MAAM,CAACE,IADQ,EAEfF,MAAM,CAACK,UAFQ,EAGf;IAAEmB,MAAM,EAAEX,UAAU,KAAK,MAAf,GAAwBK,wBAAxB,GAAmDL;EAA7D,CAHe,EAIfG,KAJe,CAAnB;EAOA,oBACI,oBAAC,QAAD,CAAU,IAAV;IACI,GAAG,EAAEL;EADT,GAEQM,UAFR;IAGI,QAAQ,EAAEL,IAAI,CAACuB,GAAL,CAASP,cAAT,CAHd;IAII,KAAK,EAAEM;EAJX,GADJ;AAQH,CAlD0B,CAA3B;AAoDA,4BAAevC,IAAI,CAACc,QAAD,CAAnB"}
@@ -1,14 +1,16 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { Animated } from 'react-native';
3
3
  import { PanGestureHandler, State as GestureHandlerState } from 'react-native-gesture-handler';
4
- const SCROLL_TO_ADJACENT_TX_THRESHOLD = 60;
5
- const SCROLL_TO_ADJACENT_VX_THRESHOLD = 500;
4
+ const SCROLL_TO_ADJACENT_TX_THRESHOLD = 80;
5
+ const SCROLL_TO_ADJACENT_VX_THRESHOLD = 1000;
6
6
  const ACTIVE_OFFSET_ABS_X = 5;
7
7
  const activeOffsetX = [-ACTIVE_OFFSET_ABS_X, ACTIVE_OFFSET_ABS_X];
8
8
  const endAnimationStates = [GestureHandlerState.CANCELLED, GestureHandlerState.END];
9
9
 
10
10
  function shouldScrollToAdjacent(translationX, velocityX) {
11
- return Math.abs(translationX) >= SCROLL_TO_ADJACENT_TX_THRESHOLD || Math.abs(velocityX) >= SCROLL_TO_ADJACENT_VX_THRESHOLD;
11
+ const isSameDirection = translationX * velocityX > 0;
12
+ const isEnoughMovement = Math.abs(translationX) >= SCROLL_TO_ADJACENT_TX_THRESHOLD || Math.abs(velocityX) >= SCROLL_TO_ADJACENT_VX_THRESHOLD;
13
+ return isSameDirection && isEnoughMovement;
12
14
  }
13
15
 
14
16
  export default function ScrollViewGesture(props) {
@@ -18,7 +20,7 @@ export default function ScrollViewGesture(props) {
18
20
  finalizeAnimation,
19
21
  offsetTx,
20
22
  scrollEnabled,
21
- startAnimation
23
+ startPagingAnimation
22
24
  } = props;
23
25
  const {
24
26
  pause: pauseAutoplay,
@@ -45,11 +47,14 @@ export default function ScrollViewGesture(props) {
45
47
  } = event;
46
48
 
47
49
  if (endAnimationStates.includes(state)) {
48
- const userDirection = shouldScrollToAdjacent(translationX, velocityX) ? translationX < 0 ? 'next' : 'prev' : 'stay';
49
- startAnimation(userDirection, true);
50
+ const direction = shouldScrollToAdjacent(translationX, velocityX) ? translationX < 0 ? 'next' : 'prev' : 'stay';
51
+ startPagingAnimation('directional', {
52
+ direction: direction,
53
+ isOriginatedFromGesture: true
54
+ });
50
55
  resumeAutoplay();
51
56
  }
52
- }, [startAnimation, resumeAutoplay]);
57
+ }, [startPagingAnimation, resumeAutoplay]);
53
58
  return /*#__PURE__*/React.createElement(PanGestureHandler, {
54
59
  activeOffsetX: activeOffsetX,
55
60
  children: children,