@fountain-ui/lab 2.0.0-beta.15 → 2.0.0-beta.18
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/build/commonjs/Carousel/Carousel.js +11 -20
- package/build/commonjs/Carousel/Carousel.js.map +1 -1
- package/build/commonjs/Carousel/CarouselProps.js.map +1 -1
- package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js +2 -2
- package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js.map +1 -1
- package/build/commonjs/Carousel/components/ItemView.js +2 -2
- package/build/commonjs/Carousel/components/ItemView.js.map +1 -1
- package/build/commonjs/Carousel/components/ScrollViewGesture.js +4 -3
- package/build/commonjs/Carousel/components/ScrollViewGesture.js.map +1 -1
- package/build/commonjs/Carousel/hooks/index.js +3 -3
- package/build/commonjs/Carousel/hooks/index.js.map +1 -1
- package/build/commonjs/Carousel/hooks/useIndexController.js +28 -12
- package/build/commonjs/Carousel/hooks/useIndexController.js.map +1 -1
- package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js +3 -3
- package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js.map +1 -1
- package/build/commonjs/Carousel/hooks/{usePagingAnimation.js → usePagingAnimator.js} +45 -21
- package/build/commonjs/Carousel/hooks/usePagingAnimator.js.map +1 -0
- package/build/commonjs/Carousel/types.js +1 -0
- package/build/commonjs/Carousel/types.js.map +1 -1
- package/build/module/Carousel/Carousel.js +13 -19
- package/build/module/Carousel/Carousel.js.map +1 -1
- package/build/module/Carousel/CarouselProps.js.map +1 -1
- package/build/module/Carousel/animation/createDefaultScrollAnimation.js +2 -2
- package/build/module/Carousel/animation/createDefaultScrollAnimation.js.map +1 -1
- package/build/module/Carousel/components/ItemView.js +2 -2
- package/build/module/Carousel/components/ItemView.js.map +1 -1
- package/build/module/Carousel/components/ScrollViewGesture.js +4 -3
- package/build/module/Carousel/components/ScrollViewGesture.js.map +1 -1
- package/build/module/Carousel/hooks/index.js +1 -1
- package/build/module/Carousel/hooks/index.js.map +1 -1
- package/build/module/Carousel/hooks/useIndexController.js +28 -13
- package/build/module/Carousel/hooks/useIndexController.js.map +1 -1
- package/build/module/Carousel/hooks/useItemVisibilityStore.js +3 -3
- package/build/module/Carousel/hooks/useItemVisibilityStore.js.map +1 -1
- package/build/module/Carousel/hooks/{usePagingAnimation.js → usePagingAnimator.js} +44 -21
- package/build/module/Carousel/hooks/usePagingAnimator.js.map +1 -0
- package/build/module/Carousel/types.js +1 -0
- package/build/module/Carousel/types.js.map +1 -1
- package/build/typescript/Carousel/CarouselProps.d.ts +2 -2
- package/build/typescript/Carousel/components/ScrollViewGesture.d.ts +1 -1
- package/build/typescript/Carousel/hooks/index.d.ts +1 -1
- package/build/typescript/Carousel/hooks/useIndexController.d.ts +3 -1
- package/build/typescript/Carousel/hooks/useItemVisibilityStore.d.ts +2 -5
- package/build/typescript/Carousel/hooks/{usePagingAnimation.d.ts → usePagingAnimator.d.ts} +6 -5
- package/build/typescript/Carousel/types.d.ts +14 -1
- package/package.json +2 -2
- package/src/Carousel/Carousel.tsx +12 -20
- package/src/Carousel/CarouselProps.ts +9 -2
- package/src/Carousel/animation/createDefaultScrollAnimation.ts +2 -2
- package/src/Carousel/components/ItemView.tsx +2 -2
- package/src/Carousel/components/ScrollViewGesture.tsx +8 -4
- package/src/Carousel/hooks/index.ts +1 -1
- package/src/Carousel/hooks/useIndexController.tsx +30 -19
- package/src/Carousel/hooks/useItemVisibilityStore.ts +5 -9
- package/src/Carousel/hooks/{usePagingAnimation.ts → usePagingAnimator.ts} +53 -25
- package/src/Carousel/types.ts +19 -1
- package/build/commonjs/Carousel/hooks/usePagingAnimation.js.map +0 -1
- package/build/module/Carousel/hooks/usePagingAnimation.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["directions"],"sources":["types.ts"],"sourcesContent":["import type { ReactElement } from 'react';\nimport type { Animated, ViewProps } from 'react-native';\n\nconst directions = ['next', 'prev', 'stay'] as const;\n\nexport type PagingDirection = (typeof directions)[number];\n\nexport type ItemHeight = number | 'auto';\n\nexport interface RenderItem<T> {\n (info: { item: T, index: number, interpolation: Animated.AnimatedInterpolation }): ReactElement | null;\n}\n\nexport interface CreateScrollAnimation {\n (aValue: Animated.AnimatedValue, toValue: number): Animated.CompositeAnimation;\n}\n\nexport interface CreateItemStyle {\n (itemInterpolation: Animated.AnimatedInterpolation, itemWidth: number): Animated.AnimatedProps<ViewProps['style']>;\n}\n\nexport interface GetCurrentIndex {\n (): number;\n}\n\nexport interface IndexController {\n getCurrentIndex: GetCurrentIndex;\n lastIndex: number;\n
|
|
1
|
+
{"version":3,"names":["directions","scrollStates"],"sources":["types.ts"],"sourcesContent":["import type { ReactElement } from 'react';\nimport type { Animated, ViewProps } from 'react-native';\n\nconst directions = ['next', 'prev', 'stay'] as const;\n\nexport type PagingDirection = (typeof directions)[number];\n\nconst scrollStates = ['idle', 'dragging', 'interrupted'] as const;\n\nexport type ScrollState = (typeof scrollStates)[number];\n\nexport type ItemHeight = number | 'auto';\n\nexport interface RenderItem<T> {\n (info: { item: T, index: number, interpolation: Animated.AnimatedInterpolation }): ReactElement | null;\n}\n\nexport interface CreateScrollAnimation {\n (aValue: Animated.AnimatedValue, toValue: number): Animated.CompositeAnimation;\n}\n\nexport interface CreateItemStyle {\n (itemInterpolation: Animated.AnimatedInterpolation, itemWidth: number): Animated.AnimatedProps<ViewProps['style']>;\n}\n\nexport interface GetCurrentIndex {\n (): number;\n}\n\nexport interface OnIndexChange {\n (itemIndex: number): void;\n}\n\nexport interface OnPositionChange {\n (position: number): void;\n}\n\nexport interface ScrollStateChangeEvent {\n offset: number;\n state: ScrollState;\n}\n\nexport interface IndexController {\n getCurrentIndex: GetCurrentIndex;\n lastIndex: number;\n notifyScrollStateHasChanged: (event: ScrollStateChangeEvent) => void;\n}\n\nexport type PagingAnimationType = 'directional' | 'index';\n\nexport interface BasePagingAnimationConfig {\n animated?: boolean;\n lastGestureTranslationX?: number;\n}\n\nexport interface DirectionalPagingAnimationConfig extends BasePagingAnimationConfig {\n direction: PagingDirection;\n isOriginatedFromGesture?: boolean;\n}\n\nexport interface IndexPagingAnimationConfig extends BasePagingAnimationConfig {\n index: number;\n}\n\nexport type PagingAnimationConfig = DirectionalPagingAnimationConfig | IndexPagingAnimationConfig;\n\nexport interface StartPagingAnimation {\n (type: PagingAnimationType, config: PagingAnimationConfig): void;\n}\n\nexport type VisibleIndexRanges = Array<[number, number]>;\n\nexport interface StoreSubscription {\n (): void;\n}\n\nexport interface ItemVisibilityStore {\n dispatch: (ranges: VisibleIndexRanges) => void;\n subscribe: (listener: (ranges: VisibleIndexRanges) => void) => StoreSubscription;\n removeAllListeners: () => void;\n}\n\nexport interface AutoplayController {\n pause: () => void;\n resume: () => void;\n}\n\nexport interface ScrollToOption {\n index: number;\n animated?: boolean;\n}\n\nexport interface CarouselInstance {\n /**\n * Get current visible item index.\n */\n getCurrentIndex: GetCurrentIndex;\n\n /**\n * Scroll to next visible item.\n */\n next: () => void;\n\n /**\n * Scroll to previous visible item.\n */\n prev: () => void;\n\n /**\n * Scroll to desired indexed item.\n * Invalid index is ignored.\n */\n scrollTo: (option: ScrollToOption) => void;\n}\n"],"mappings":";;;;;AAGA,MAAMA,UAAU,GAAG,CAAC,MAAD,EAAS,MAAT,EAAiB,MAAjB,CAAnB;AAIA,MAAMC,YAAY,GAAG,CAAC,MAAD,EAAS,UAAT,EAAqB,aAArB,CAArB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React, { forwardRef, memo,
|
|
2
|
-
import { Animated } from 'react-native';
|
|
1
|
+
import React, { forwardRef, memo, useImperativeHandle, useMemo } from 'react';
|
|
3
2
|
import ViewabilityTrackerView from '../ViewabilityTrackerView';
|
|
4
|
-
import { useAutoplayController, useIndexController, useItemVisibilityStore, useLoopedData,
|
|
3
|
+
import { useAutoplayController, useIndexController, useItemVisibilityStore, useLoopedData, usePagingAnimator } from './hooks';
|
|
5
4
|
import { createDefaultItemStyle, createDefaultScrollAnimation } from './animation';
|
|
6
5
|
import { InternalContext, RootView, ScrollViewGesture } from './components';
|
|
7
6
|
const Carousel = /*#__PURE__*/forwardRef(function Carousel(props, ref) {
|
|
@@ -16,46 +15,41 @@ const Carousel = /*#__PURE__*/forwardRef(function Carousel(props, ref) {
|
|
|
16
15
|
itemHeight,
|
|
17
16
|
itemWidth,
|
|
18
17
|
loop = false,
|
|
19
|
-
onIndexChange
|
|
18
|
+
onIndexChange,
|
|
20
19
|
renderItem,
|
|
21
20
|
scrollEnabled = true,
|
|
22
21
|
style,
|
|
23
22
|
windowSize = 5
|
|
24
23
|
} = props;
|
|
25
24
|
const data = useLoopedData(originalData, loop);
|
|
26
|
-
const
|
|
27
|
-
const offsetX = useRef(new Animated.Value(initialTx)).current;
|
|
28
|
-
const translateX = useRef(new Animated.Value(0)).current;
|
|
29
|
-
const globalInterpolation = Animated.add(offsetX, translateX);
|
|
30
|
-
const [itemVisibilityStore, onIndexChange] = useItemVisibilityStore({
|
|
25
|
+
const [itemVisibilityStore, onPositionChange] = useItemVisibilityStore({
|
|
31
26
|
initialIndex,
|
|
32
27
|
numberOfData: data.length,
|
|
33
28
|
windowSize
|
|
34
29
|
});
|
|
35
|
-
const handleIndexChange = useCallback(newIndex => {
|
|
36
|
-
onIndexChange(newIndex);
|
|
37
|
-
onIndexChangeProp === null || onIndexChangeProp === void 0 ? void 0 : onIndexChangeProp(newIndex);
|
|
38
|
-
}, [onIndexChange, onIndexChangeProp]);
|
|
39
30
|
const indexController = useIndexController({
|
|
40
31
|
initialIndex,
|
|
41
32
|
itemWidth,
|
|
33
|
+
numberOfData: data.length,
|
|
42
34
|
numberOfOriginalData: originalData.length,
|
|
43
|
-
onIndexChange
|
|
35
|
+
onIndexChange,
|
|
36
|
+
onPositionChange
|
|
44
37
|
});
|
|
45
38
|
const {
|
|
46
39
|
getCurrentIndex
|
|
47
40
|
} = indexController;
|
|
48
41
|
const {
|
|
42
|
+
gestureTranslationX,
|
|
43
|
+
globalInterpolation,
|
|
49
44
|
interruptAnimation,
|
|
50
45
|
startPagingAnimation
|
|
51
|
-
} =
|
|
46
|
+
} = usePagingAnimator({
|
|
52
47
|
createScrollAnimation,
|
|
53
48
|
itemWidth,
|
|
54
49
|
indexController,
|
|
50
|
+
initialIndex,
|
|
55
51
|
loop,
|
|
56
|
-
numberOfData: data.length
|
|
57
|
-
offsetX,
|
|
58
|
-
translateX
|
|
52
|
+
numberOfData: data.length
|
|
59
53
|
});
|
|
60
54
|
const autoplayController = useAutoplayController({
|
|
61
55
|
enabled: autoplay,
|
|
@@ -99,8 +93,8 @@ const Carousel = /*#__PURE__*/forwardRef(function Carousel(props, ref) {
|
|
|
99
93
|
}
|
|
100
94
|
}, /*#__PURE__*/React.createElement(ScrollViewGesture, {
|
|
101
95
|
autoplayController: autoplayController,
|
|
96
|
+
gestureTranslationX: gestureTranslationX,
|
|
102
97
|
interruptAnimation: interruptAnimation,
|
|
103
|
-
translateX: translateX,
|
|
104
98
|
scrollEnabled: scrollEnabled,
|
|
105
99
|
startPagingAnimation: startPagingAnimation
|
|
106
100
|
}, /*#__PURE__*/React.createElement(RootView, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","forwardRef","memo","
|
|
1
|
+
{"version":3,"names":["React","forwardRef","memo","useImperativeHandle","useMemo","ViewabilityTrackerView","useAutoplayController","useIndexController","useItemVisibilityStore","useLoopedData","usePagingAnimator","createDefaultItemStyle","createDefaultScrollAnimation","InternalContext","RootView","ScrollViewGesture","Carousel","props","ref","autoplay","autoplayInterval","createItemStyle","createScrollAnimation","data","originalData","disableSmartAutoplay","initialIndex","itemHeight","itemWidth","loop","onIndexChange","renderItem","scrollEnabled","style","windowSize","itemVisibilityStore","onPositionChange","numberOfData","length","indexController","numberOfOriginalData","getCurrentIndex","gestureTranslationX","globalInterpolation","interruptAnimation","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 } from 'react';\nimport ViewabilityTrackerView from '../ViewabilityTrackerView';\nimport type CarouselProps from './CarouselProps';\nimport type { CarouselInstance } from './types';\nimport {\n useAutoplayController,\n useIndexController,\n useItemVisibilityStore,\n useLoopedData,\n usePagingAnimator,\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 [itemVisibilityStore, onPositionChange] = useItemVisibilityStore({\n initialIndex,\n numberOfData: data.length,\n windowSize,\n });\n\n const indexController = useIndexController({\n initialIndex,\n itemWidth,\n numberOfData: data.length,\n numberOfOriginalData: originalData.length,\n onIndexChange,\n onPositionChange,\n });\n\n const { getCurrentIndex } = indexController;\n\n const {\n gestureTranslationX,\n globalInterpolation,\n interruptAnimation,\n startPagingAnimation,\n } = usePagingAnimator({\n createScrollAnimation,\n itemWidth,\n indexController,\n initialIndex,\n loop,\n numberOfData: data.length,\n });\n\n const autoplayController = useAutoplayController({\n enabled: autoplay,\n intervalMillis: autoplayInterval,\n startPagingAnimation,\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 <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 gestureTranslationX={gestureTranslationX}\n interruptAnimation={interruptAnimation}\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,QAAsE,OAAtE;AACA,OAAOC,sBAAP,MAAmC,2BAAnC;AAGA,SACIC,qBADJ,EAEIC,kBAFJ,EAGIC,sBAHJ,EAIIC,aAJJ,EAKIC,iBALJ,QAMO,SANP;AAOA,SAASC,sBAAT,EAAiCC,4BAAjC,QAAqE,aAArE;AACA,SAASC,eAAT,EAA0BC,QAA1B,EAAoCC,iBAApC,QAA6D,cAA7D;AAEA,MAAMC,QAAQ,gBAAGf,UAAU,CAAkC,SAASe,QAAT,CAAkBC,KAAlB,EAAyBC,GAAzB,EAA8B;EACvF,MAAM;IACFC,QAAQ,GAAG,KADT;IAEFC,gBAAgB,GAAG,IAFjB;IAGFC,eAAe,GAAGV,sBAHhB;IAIFW,qBAAqB,GAAGV,4BAJtB;IAKFW,IAAI,EAAEC,YALJ;IAMFC,oBAAoB,GAAG,KANrB;IAOFC,YAAY,GAAG,CAPb;IA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":[],"sources":["CarouselProps.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\nimport type {
|
|
1
|
+
{"version":3,"names":[],"sources":["CarouselProps.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\nimport type {\n CarouselInstance,\n CreateItemStyle,\n CreateScrollAnimation,\n ItemHeight,\n OnIndexChange,\n RenderItem,\n} 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?: OnIndexChange;\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":""}
|
|
@@ -2,8 +2,8 @@ import { Animated, Easing } from 'react-native';
|
|
|
2
2
|
export default function createDefaultScrollAnimation(animatedValue, toValue) {
|
|
3
3
|
return Animated.timing(animatedValue, {
|
|
4
4
|
toValue: toValue,
|
|
5
|
-
duration:
|
|
6
|
-
easing: Easing.bezier(0.
|
|
5
|
+
duration: 180,
|
|
6
|
+
easing: Easing.bezier(0.2, 0.2, 0.2, 1),
|
|
7
7
|
useNativeDriver: true
|
|
8
8
|
});
|
|
9
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Animated","Easing","createDefaultScrollAnimation","animatedValue","toValue","timing","duration","easing","bezier","useNativeDriver"],"sources":["createDefaultScrollAnimation.ts"],"sourcesContent":["import { Animated, Easing } from 'react-native';\n\nexport default function createDefaultScrollAnimation(\n animatedValue: Animated.Value,\n toValue: number,\n): Animated.CompositeAnimation {\n return Animated.timing(animatedValue, {\n toValue: toValue,\n duration:
|
|
1
|
+
{"version":3,"names":["Animated","Easing","createDefaultScrollAnimation","animatedValue","toValue","timing","duration","easing","bezier","useNativeDriver"],"sources":["createDefaultScrollAnimation.ts"],"sourcesContent":["import { Animated, Easing } from 'react-native';\n\nexport default function createDefaultScrollAnimation(\n animatedValue: Animated.Value,\n toValue: number,\n): Animated.CompositeAnimation {\n return Animated.timing(animatedValue, {\n toValue: toValue,\n duration: 180,\n easing: Easing.bezier(0.2, 0.2, 0.2, 1),\n useNativeDriver: true,\n });\n};\n"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,MAAnB,QAAiC,cAAjC;AAEA,eAAe,SAASC,4BAAT,CACXC,aADW,EAEXC,OAFW,EAGgB;EAC3B,OAAOJ,QAAQ,CAACK,MAAT,CAAgBF,aAAhB,EAA+B;IAClCC,OAAO,EAAEA,OADyB;IAElCE,QAAQ,EAAE,GAFwB;IAGlCC,MAAM,EAAEN,MAAM,CAACO,MAAP,CAAc,GAAd,EAAmB,GAAnB,EAAwB,GAAxB,EAA6B,CAA7B,CAH0B;IAIlCC,eAAe,EAAE;EAJiB,CAA/B,CAAP;AAMH;AAAA"}
|
|
@@ -17,7 +17,7 @@ export default function ItemView(props) {
|
|
|
17
17
|
} = useContext(InternalContext);
|
|
18
18
|
const [visible, setVisible] = useState(false);
|
|
19
19
|
const interpolation = useItemInterpolation(index);
|
|
20
|
-
const itemStyle = useMemo(() => createItemStyle(interpolation, itemWidth), [createItemStyle, interpolation]);
|
|
20
|
+
const itemStyle = useMemo(() => createItemStyle(interpolation, itemWidth), [createItemStyle, interpolation, itemWidth]);
|
|
21
21
|
useEffect(() => {
|
|
22
22
|
return itemVisibilityStore.subscribe(ranges => {
|
|
23
23
|
const nextVisible = ranges.some(_ref => {
|
|
@@ -26,7 +26,7 @@ export default function ItemView(props) {
|
|
|
26
26
|
});
|
|
27
27
|
setVisible(nextVisible);
|
|
28
28
|
});
|
|
29
|
-
}, [itemVisibilityStore]);
|
|
29
|
+
}, [index, itemVisibilityStore]);
|
|
30
30
|
return /*#__PURE__*/React.createElement(Animated.View, {
|
|
31
31
|
children: visible ? children(interpolation) : null,
|
|
32
32
|
onLayout: onLayout,
|
|
@@ -1 +1 @@
|
|
|
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 './useItemInterpolation';\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,OAAOC,oBAAP,MAAiC,wBAAjC;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;
|
|
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 './useItemInterpolation';\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, itemWidth],\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 }, [index, 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,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,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"}
|
|
@@ -18,7 +18,7 @@ export default function ScrollViewGesture(props) {
|
|
|
18
18
|
autoplayController,
|
|
19
19
|
children,
|
|
20
20
|
interruptAnimation,
|
|
21
|
-
|
|
21
|
+
gestureTranslationX,
|
|
22
22
|
scrollEnabled,
|
|
23
23
|
startPagingAnimation
|
|
24
24
|
} = props;
|
|
@@ -32,7 +32,7 @@ export default function ScrollViewGesture(props) {
|
|
|
32
32
|
}, [interruptAnimation, pauseAutoplay]);
|
|
33
33
|
const handleGestureEvent = useCallback(Animated.event([{
|
|
34
34
|
nativeEvent: {
|
|
35
|
-
translationX:
|
|
35
|
+
translationX: gestureTranslationX
|
|
36
36
|
}
|
|
37
37
|
}], {
|
|
38
38
|
useNativeDriver: true
|
|
@@ -50,7 +50,8 @@ export default function ScrollViewGesture(props) {
|
|
|
50
50
|
const direction = shouldScrollToAdjacent(translationX, velocityX) ? translationX < 0 ? 'next' : 'prev' : 'stay';
|
|
51
51
|
startPagingAnimation('directional', {
|
|
52
52
|
direction: direction,
|
|
53
|
-
isOriginatedFromGesture: true
|
|
53
|
+
isOriginatedFromGesture: true,
|
|
54
|
+
lastGestureTranslationX: translationX
|
|
54
55
|
});
|
|
55
56
|
resumeAutoplay();
|
|
56
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","Animated","PanGestureHandler","State","GestureHandlerState","SCROLL_TO_ADJACENT_TX_THRESHOLD","SCROLL_TO_ADJACENT_VX_THRESHOLD","ACTIVE_OFFSET_ABS_X","activeOffsetX","endAnimationStates","CANCELLED","END","FAILED","shouldScrollToAdjacent","translationX","velocityX","isSameDirection","isEnoughMovement","Math","abs","ScrollViewGesture","props","autoplayController","children","interruptAnimation","
|
|
1
|
+
{"version":3,"names":["React","useCallback","Animated","PanGestureHandler","State","GestureHandlerState","SCROLL_TO_ADJACENT_TX_THRESHOLD","SCROLL_TO_ADJACENT_VX_THRESHOLD","ACTIVE_OFFSET_ABS_X","activeOffsetX","endAnimationStates","CANCELLED","END","FAILED","shouldScrollToAdjacent","translationX","velocityX","isSameDirection","isEnoughMovement","Math","abs","ScrollViewGesture","props","autoplayController","children","interruptAnimation","gestureTranslationX","scrollEnabled","startPagingAnimation","pause","pauseAutoplay","resume","resumeAutoplay","handleGestureBegin","handleGestureEvent","event","nativeEvent","useNativeDriver","handleHandlerStateChange","state","includes","direction","isOriginatedFromGesture","lastGestureTranslationX"],"sources":["ScrollViewGesture.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport React, { useCallback } from 'react';\nimport { Animated } from 'react-native';\nimport type { PanGestureHandlerStateChangeEvent } from 'react-native-gesture-handler';\nimport { PanGestureHandler, State as GestureHandlerState } from 'react-native-gesture-handler';\nimport type { AutoplayController, PagingDirection, StartPagingAnimation } from '../types';\n\nexport interface ScrollViewGestureProps {\n autoplayController: AutoplayController;\n children: ReactNode;\n gestureTranslationX: Animated.Value,\n interruptAnimation: () => void;\n scrollEnabled: boolean;\n startPagingAnimation: StartPagingAnimation;\n}\n\nconst SCROLL_TO_ADJACENT_TX_THRESHOLD = 80;\nconst SCROLL_TO_ADJACENT_VX_THRESHOLD = 1000;\n\nconst ACTIVE_OFFSET_ABS_X = 5;\nconst activeOffsetX: number[] = [-ACTIVE_OFFSET_ABS_X, ACTIVE_OFFSET_ABS_X];\n\nconst endAnimationStates: Readonly<GestureHandlerState[]> = [\n GestureHandlerState.CANCELLED,\n GestureHandlerState.END,\n GestureHandlerState.FAILED,\n];\n\nfunction shouldScrollToAdjacent(translationX: number, velocityX: number): boolean {\n const isSameDirection = translationX * velocityX > 0;\n const isEnoughMovement =\n Math.abs(translationX) >= SCROLL_TO_ADJACENT_TX_THRESHOLD\n || Math.abs(velocityX) >= SCROLL_TO_ADJACENT_VX_THRESHOLD;\n\n return isSameDirection && isEnoughMovement;\n}\n\nexport default function ScrollViewGesture(props: ScrollViewGestureProps) {\n const {\n autoplayController,\n children,\n interruptAnimation,\n gestureTranslationX,\n scrollEnabled,\n startPagingAnimation,\n } = props;\n\n const { pause: pauseAutoplay, resume: resumeAutoplay } = autoplayController;\n\n const handleGestureBegin = useCallback(() => {\n pauseAutoplay();\n\n interruptAnimation();\n }, [interruptAnimation, pauseAutoplay]);\n\n const handleGestureEvent = useCallback(Animated.event(\n [{ nativeEvent: { translationX: gestureTranslationX } }],\n { useNativeDriver: true },\n ), []);\n\n const handleHandlerStateChange = useCallback((event: PanGestureHandlerStateChangeEvent) => {\n const { nativeEvent: { translationX, velocityX, state } } = event;\n\n if (endAnimationStates.includes(state)) {\n const direction: PagingDirection = shouldScrollToAdjacent(translationX, velocityX)\n ? (translationX < 0 ? 'next' : 'prev')\n : 'stay';\n\n startPagingAnimation(\n 'directional',\n {\n direction: direction,\n isOriginatedFromGesture: true,\n lastGestureTranslationX: translationX,\n },\n );\n\n resumeAutoplay();\n }\n }, [startPagingAnimation, resumeAutoplay]);\n\n return (\n <PanGestureHandler\n activeOffsetX={activeOffsetX}\n children={children}\n enabled={scrollEnabled}\n onBegan={handleGestureBegin}\n onGestureEvent={handleGestureEvent}\n onHandlerStateChange={handleHandlerStateChange}\n />\n );\n}\n"],"mappings":"AACA,OAAOA,KAAP,IAAgBC,WAAhB,QAAmC,OAAnC;AACA,SAASC,QAAT,QAAyB,cAAzB;AAEA,SAASC,iBAAT,EAA4BC,KAAK,IAAIC,mBAArC,QAAgE,8BAAhE;AAYA,MAAMC,+BAA+B,GAAG,EAAxC;AACA,MAAMC,+BAA+B,GAAG,IAAxC;AAEA,MAAMC,mBAAmB,GAAG,CAA5B;AACA,MAAMC,aAAuB,GAAG,CAAC,CAACD,mBAAF,EAAuBA,mBAAvB,CAAhC;AAEA,MAAME,kBAAmD,GAAG,CACxDL,mBAAmB,CAACM,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,CAAtB,GAC5BD,YAAY,GAAG,CAAf,GAAmB,MAAnB,GAA4B,MADA,GAE7B,MAFN;MAIAa,oBAAoB,CAChB,aADgB,EAEhB;QACIa,SAAS,EAAEA,SADf;QAEIC,uBAAuB,EAAE,IAF7B;QAGIC,uBAAuB,EAAE5B;MAH7B,CAFgB,CAApB;MASAiB,cAAc;IACjB;EACJ,CAnB2C,EAmBzC,CAACJ,oBAAD,EAAuBI,cAAvB,CAnByC,CAA5C;EAqBA,oBACI,oBAAC,iBAAD;IACI,aAAa,EAAEvB,aADnB;IAEI,QAAQ,EAAEe,QAFd;IAGI,OAAO,EAAEG,aAHb;IAII,OAAO,EAAEM,kBAJb;IAKI,cAAc,EAAEC,kBALpB;IAMI,oBAAoB,EAAEI;EAN1B,EADJ;AAUH"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { default as useAutoplayController } from './useAutoplayController';
|
|
2
2
|
export { default as useIndexController } from './useIndexController';
|
|
3
3
|
export { default as useLoopedData } from './useLoopedData';
|
|
4
|
-
export { default as
|
|
4
|
+
export { default as usePagingAnimator } from './usePagingAnimator';
|
|
5
5
|
export { default as useItemVisibilityStore } from './useItemVisibilityStore';
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","useAutoplayController","useIndexController","useLoopedData","
|
|
1
|
+
{"version":3,"names":["default","useAutoplayController","useIndexController","useLoopedData","usePagingAnimator","useItemVisibilityStore"],"sources":["index.ts"],"sourcesContent":["export { default as useAutoplayController } from './useAutoplayController';\nexport { default as useIndexController } from './useIndexController';\nexport { default as useLoopedData } from './useLoopedData';\nexport { default as usePagingAnimator } from './usePagingAnimator';\nexport { default as useItemVisibilityStore } from './useItemVisibilityStore';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,qBAApB,QAAiD,yBAAjD;AACA,SAASD,OAAO,IAAIE,kBAApB,QAA8C,sBAA9C;AACA,SAASF,OAAO,IAAIG,aAApB,QAAyC,iBAAzC;AACA,SAASH,OAAO,IAAII,iBAApB,QAA6C,qBAA7C;AACA,SAASJ,OAAO,IAAIK,sBAApB,QAAkD,0BAAlD"}
|
|
@@ -1,28 +1,43 @@
|
|
|
1
|
-
import { useCallback
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useImperativeState } from '@fountain-ui/core';
|
|
2
3
|
import { mod } from '@fountain-ui/utils';
|
|
3
4
|
export default function useIndexController(params) {
|
|
4
5
|
const {
|
|
5
6
|
initialIndex,
|
|
6
7
|
itemWidth,
|
|
8
|
+
numberOfData,
|
|
7
9
|
numberOfOriginalData,
|
|
8
|
-
onIndexChange
|
|
10
|
+
onIndexChange,
|
|
11
|
+
onPositionChange
|
|
9
12
|
} = params;
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
13
|
+
const currentIndex = useImperativeState(initialIndex);
|
|
14
|
+
const currentPosition = useImperativeState(initialIndex);
|
|
15
|
+
const notifyScrollStateHasChanged = useCallback(_ref => {
|
|
16
|
+
let {
|
|
17
|
+
offset,
|
|
18
|
+
state
|
|
19
|
+
} = _ref;
|
|
20
|
+
const normalized = -Math.round(offset / itemWidth);
|
|
21
|
+
const index = Math.floor(mod(normalized, numberOfOriginalData));
|
|
22
|
+
const position = Math.floor(mod(normalized, numberOfData));
|
|
14
23
|
|
|
15
|
-
|
|
24
|
+
if (state === 'idle' || state === 'interrupted') {
|
|
25
|
+
if (currentIndex.hasChanged()) {
|
|
26
|
+
onIndexChange === null || onIndexChange === void 0 ? void 0 : onIndexChange(currentIndex.get());
|
|
27
|
+
}
|
|
16
28
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
29
|
+
if (currentPosition.hasChanged()) {
|
|
30
|
+
onPositionChange === null || onPositionChange === void 0 ? void 0 : onPositionChange(currentPosition.get());
|
|
31
|
+
}
|
|
20
32
|
}
|
|
21
|
-
|
|
33
|
+
|
|
34
|
+
currentIndex.set(index);
|
|
35
|
+
currentPosition.set(position);
|
|
36
|
+
}, [itemWidth, numberOfData, numberOfOriginalData, onIndexChange, onPositionChange]);
|
|
22
37
|
return {
|
|
23
|
-
getCurrentIndex,
|
|
38
|
+
getCurrentIndex: currentIndex.get,
|
|
24
39
|
lastIndex: numberOfOriginalData - 1,
|
|
25
|
-
|
|
40
|
+
notifyScrollStateHasChanged
|
|
26
41
|
};
|
|
27
42
|
}
|
|
28
43
|
;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","
|
|
1
|
+
{"version":3,"names":["useCallback","useImperativeState","mod","useIndexController","params","initialIndex","itemWidth","numberOfData","numberOfOriginalData","onIndexChange","onPositionChange","currentIndex","currentPosition","notifyScrollStateHasChanged","offset","state","normalized","Math","round","index","floor","position","hasChanged","get","set","getCurrentIndex","lastIndex"],"sources":["useIndexController.tsx"],"sourcesContent":["import { useCallback } from 'react';\nimport { useImperativeState } from '@fountain-ui/core';\nimport { mod } from '@fountain-ui/utils';\nimport type { IndexController, ScrollStateChangeEvent } from '../types';\n\nexport interface UseIndexControllerParameters {\n initialIndex: number;\n itemWidth: number;\n numberOfData: number;\n numberOfOriginalData: number;\n onIndexChange?: (itemIndex: number) => void;\n onPositionChange?: (position: number) => void;\n}\n\nexport default function useIndexController(params: UseIndexControllerParameters): IndexController {\n const {\n initialIndex,\n itemWidth,\n numberOfData,\n numberOfOriginalData,\n onIndexChange,\n onPositionChange,\n } = params;\n\n const currentIndex = useImperativeState(initialIndex);\n const currentPosition = useImperativeState(initialIndex);\n\n const notifyScrollStateHasChanged = useCallback(({ offset, state }: ScrollStateChangeEvent) => {\n const normalized = -Math.round(offset / itemWidth);\n const index = Math.floor(mod(normalized, numberOfOriginalData));\n const position = Math.floor(mod(normalized, numberOfData));\n\n if (state === 'idle' || state === 'interrupted') {\n if (currentIndex.hasChanged()) {\n onIndexChange?.(currentIndex.get());\n }\n if (currentPosition.hasChanged()) {\n onPositionChange?.(currentPosition.get());\n }\n }\n\n currentIndex.set(index);\n currentPosition.set(position);\n }, [\n itemWidth,\n numberOfData,\n numberOfOriginalData,\n onIndexChange,\n onPositionChange,\n ]);\n\n return {\n getCurrentIndex: currentIndex.get,\n lastIndex: numberOfOriginalData - 1,\n notifyScrollStateHasChanged,\n };\n};\n"],"mappings":"AAAA,SAASA,WAAT,QAA4B,OAA5B;AACA,SAASC,kBAAT,QAAmC,mBAAnC;AACA,SAASC,GAAT,QAAoB,oBAApB;AAYA,eAAe,SAASC,kBAAT,CAA4BC,MAA5B,EAAmF;EAC9F,MAAM;IACFC,YADE;IAEFC,SAFE;IAGFC,YAHE;IAIFC,oBAJE;IAKFC,aALE;IAMFC;EANE,IAOFN,MAPJ;EASA,MAAMO,YAAY,GAAGV,kBAAkB,CAACI,YAAD,CAAvC;EACA,MAAMO,eAAe,GAAGX,kBAAkB,CAACI,YAAD,CAA1C;EAEA,MAAMQ,2BAA2B,GAAGb,WAAW,CAAC,QAA+C;IAAA,IAA9C;MAAEc,MAAF;MAAUC;IAAV,CAA8C;IAC3F,MAAMC,UAAU,GAAG,CAACC,IAAI,CAACC,KAAL,CAAWJ,MAAM,GAAGR,SAApB,CAApB;IACA,MAAMa,KAAK,GAAGF,IAAI,CAACG,KAAL,CAAWlB,GAAG,CAACc,UAAD,EAAaR,oBAAb,CAAd,CAAd;IACA,MAAMa,QAAQ,GAAGJ,IAAI,CAACG,KAAL,CAAWlB,GAAG,CAACc,UAAD,EAAaT,YAAb,CAAd,CAAjB;;IAEA,IAAIQ,KAAK,KAAK,MAAV,IAAoBA,KAAK,KAAK,aAAlC,EAAiD;MAC7C,IAAIJ,YAAY,CAACW,UAAb,EAAJ,EAA+B;QAC3Bb,aAAa,SAAb,IAAAA,aAAa,WAAb,YAAAA,aAAa,CAAGE,YAAY,CAACY,GAAb,EAAH,CAAb;MACH;;MACD,IAAIX,eAAe,CAACU,UAAhB,EAAJ,EAAkC;QAC9BZ,gBAAgB,SAAhB,IAAAA,gBAAgB,WAAhB,YAAAA,gBAAgB,CAAGE,eAAe,CAACW,GAAhB,EAAH,CAAhB;MACH;IACJ;;IAEDZ,YAAY,CAACa,GAAb,CAAiBL,KAAjB;IACAP,eAAe,CAACY,GAAhB,CAAoBH,QAApB;EACH,CAhB8C,EAgB5C,CACCf,SADD,EAECC,YAFD,EAGCC,oBAHD,EAICC,aAJD,EAKCC,gBALD,CAhB4C,CAA/C;EAwBA,OAAO;IACHe,eAAe,EAAEd,YAAY,CAACY,GAD3B;IAEHG,SAAS,EAAElB,oBAAoB,GAAG,CAF/B;IAGHK;EAHG,CAAP;AAKH;AAAA"}
|
|
@@ -71,8 +71,8 @@ export default function useItemVisibilityStore(params) {
|
|
|
71
71
|
return makeVisibleIndexRanges(numberOfData, windowSize, initialIndex);
|
|
72
72
|
});
|
|
73
73
|
const store = useRef(new SimpleItemVisibilityStore(initialRange)).current;
|
|
74
|
-
const
|
|
75
|
-
const newRanges = makeVisibleIndexRanges(numberOfData, windowSize,
|
|
74
|
+
const onPositionChange = useCallback(position => {
|
|
75
|
+
const newRanges = makeVisibleIndexRanges(numberOfData, windowSize, position);
|
|
76
76
|
store.dispatch(newRanges);
|
|
77
77
|
}, [numberOfData, windowSize]);
|
|
78
78
|
useEffect(() => {
|
|
@@ -80,7 +80,7 @@ export default function useItemVisibilityStore(params) {
|
|
|
80
80
|
store.removeAllListeners();
|
|
81
81
|
};
|
|
82
82
|
}, []);
|
|
83
|
-
return [store,
|
|
83
|
+
return [store, onPositionChange];
|
|
84
84
|
}
|
|
85
85
|
;
|
|
86
86
|
//# sourceMappingURL=useItemVisibilityStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useEffect","useRef","useState","mod","SimpleItemVisibilityStore","constructor","initialValue","store","subscribe","listener","listeners","push","index","indexOf","splice","dispatch","ranges","id","removeAllListeners","length","normalize","windowSize","numberOfData","makeVisibleIndexRanges","ws","firstIndex","lastIndex","halfNumberOfAdjacent","Math","floor","leftSide","rightSide","leftRanges","rightRanges","useItemVisibilityStore","params","initialIndex","initialRange","current","
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useRef","useState","mod","SimpleItemVisibilityStore","constructor","initialValue","store","subscribe","listener","listeners","push","index","indexOf","splice","dispatch","ranges","id","removeAllListeners","length","normalize","windowSize","numberOfData","makeVisibleIndexRanges","ws","firstIndex","lastIndex","halfNumberOfAdjacent","Math","floor","leftSide","rightSide","leftRanges","rightRanges","useItemVisibilityStore","params","initialIndex","initialRange","current","onPositionChange","position","newRanges"],"sources":["useItemVisibilityStore.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { mod } from '@fountain-ui/utils';\nimport type { ItemVisibilityStore, OnPositionChange, VisibleIndexRanges } from '../types';\n\nexport interface Parameters {\n initialIndex: number;\n numberOfData: number;\n windowSize: number;\n}\n\nclass SimpleItemVisibilityStore implements ItemVisibilityStore {\n\n private store: VisibleIndexRanges;\n\n constructor(initialValue: VisibleIndexRanges) {\n this.store = initialValue;\n }\n\n private listeners: Array<(ranges: VisibleIndexRanges) => void> = [];\n\n subscribe(listener: (ranges: VisibleIndexRanges) => void) {\n this.listeners.push(listener);\n\n listener(this.store);\n\n return () => {\n const index = this.listeners.indexOf(listener);\n this.listeners.splice(index, 1);\n };\n }\n\n dispatch(ranges: VisibleIndexRanges): void {\n this.store = ranges;\n for (const id in this.listeners) {\n const listener = this.listeners[id];\n listener?.(ranges);\n }\n }\n\n removeAllListeners(): void {\n this.listeners.splice(0, this.listeners.length);\n }\n\n}\n\nfunction normalize(windowSize: number, numberOfData: number): number {\n if (windowSize <= 0) {\n return numberOfData;\n }\n if (windowSize > 0 && windowSize % 2 === 0) {\n return windowSize + 1;\n }\n return windowSize;\n}\n\nfunction makeVisibleIndexRanges(numberOfData: number, windowSize: number, index: number): VisibleIndexRanges {\n const ws = normalize(windowSize, numberOfData);\n\n const firstIndex = 0;\n const lastIndex = numberOfData - 1;\n const halfNumberOfAdjacent = Math.floor(ws / 2);\n\n const leftSide = index - halfNumberOfAdjacent;\n const rightSide = index + halfNumberOfAdjacent;\n\n const leftRanges = leftSide >= 0\n ? [[leftSide, index]]\n : [[firstIndex, index], [mod(leftSide, numberOfData), lastIndex]];\n\n const rightRanges = rightSide < numberOfData\n ? [[index, rightSide]]\n : [[index, lastIndex], [firstIndex, mod(rightSide, numberOfData)]];\n\n // @ts-ignore\n return [\n ...leftRanges,\n ...rightRanges,\n ];\n}\n\nexport default function useItemVisibilityStore(params: Parameters): [ItemVisibilityStore, OnPositionChange] {\n const {\n initialIndex,\n numberOfData,\n windowSize,\n } = params;\n\n const [initialRange] = useState(() => {\n return makeVisibleIndexRanges(numberOfData, windowSize, initialIndex);\n });\n\n const store = useRef(new SimpleItemVisibilityStore(initialRange)).current;\n\n const onPositionChange: OnPositionChange = useCallback((position) => {\n const newRanges = makeVisibleIndexRanges(numberOfData, windowSize, position);\n\n store.dispatch(newRanges);\n }, [numberOfData, windowSize]);\n\n useEffect(() => {\n return () => {\n store.removeAllListeners();\n };\n }, []);\n\n return [store, onPositionChange];\n};\n"],"mappings":";;AAAA,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,EAAyCC,QAAzC,QAAyD,OAAzD;AACA,SAASC,GAAT,QAAoB,oBAApB;;AASA,MAAMC,yBAAN,CAA+D;EAI3DC,WAAW,CAACC,YAAD,EAAmC;IAAA;;IAAA,mCAImB,EAJnB;;IAC1C,KAAKC,KAAL,GAAaD,YAAb;EACH;;EAIDE,SAAS,CAACC,QAAD,EAAiD;IACtD,KAAKC,SAAL,CAAeC,IAAf,CAAoBF,QAApB;IAEAA,QAAQ,CAAC,KAAKF,KAAN,CAAR;IAEA,OAAO,MAAM;MACT,MAAMK,KAAK,GAAG,KAAKF,SAAL,CAAeG,OAAf,CAAuBJ,QAAvB,CAAd;MACA,KAAKC,SAAL,CAAeI,MAAf,CAAsBF,KAAtB,EAA6B,CAA7B;IACH,CAHD;EAIH;;EAEDG,QAAQ,CAACC,MAAD,EAAm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AIA,MAAMO,WAAW,GAAGF,SAAS,GAAGT,YAAZ,GACd,CAAC,CAACV,KAAD,EAAQmB,SAAR,CAAD,CADc,GAEd,CAAC,CAACnB,KAAD,EAAQc,SAAR,CAAD,EAAqB,CAACD,UAAD,EAAatB,GAAG,CAAC4B,SAAD,EAAYT,YAAZ,CAAhB,CAArB,CAFN,CAdyG,CAkBzG;;EACA,OAAO,CACH,GAAGU,UADA,EAEH,GAAGC,WAFA,CAAP;AAIH;;AAED,eAAe,SAASC,sBAAT,CAAgCC,MAAhC,EAA6F;EACxG,MAAM;IACFC,YADE;IAEFd,YAFE;IAGFD;EAHE,IAIFc,MAJJ;EAMA,MAAM,CAACE,YAAD,IAAiBnC,QAAQ,CAAC,MAAM;IAClC,OAAOqB,sBAAsB,CAACD,YAAD,EAAeD,UAAf,EAA2Be,YAA3B,CAA7B;EACH,CAF8B,CAA/B;EAIA,MAAM7B,KAAK,GAAGN,MAAM,CAAC,IAAIG,yBAAJ,CAA8BiC,YAA9B,CAAD,CAAN,CAAoDC,OAAlE;EAEA,MAAMC,gBAAkC,GAAGxC,WAAW,CAAEyC,QAAD,IAAc;IACjE,MAAMC,SAAS,GAAGlB,sBAAsB,CAACD,YAAD,EAAeD,UAAf,EAA2BmB,QAA3B,CAAxC;IAEAjC,KAAK,CAACQ,QAAN,CAAe0B,SAAf;EACH,CAJqD,EAInD,CAACnB,YAAD,EAAeD,UAAf,CAJmD,CAAtD;EAMArB,SAAS,CAAC,MAAM;IACZ,OAAO,MAAM;MACTO,KAAK,CAACW,kBAAN;IACH,CAFD;EAGH,CAJQ,EAIN,EAJM,CAAT;EAMA,OAAO,CAACX,KAAD,EAAQgC,gBAAR,CAAP;AACH;AAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { useCallback, useRef } from 'react';
|
|
1
|
+
import { useCallback, useMemo, useRef } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
2
3
|
|
|
3
4
|
function directionToValue(itemWidth) {
|
|
4
5
|
return function (direction) {
|
|
@@ -25,21 +26,27 @@ function toValueCompensator(itemWidth) {
|
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
export default function
|
|
29
|
+
export default function usePagingAnimator(config) {
|
|
29
30
|
const {
|
|
30
31
|
createScrollAnimation,
|
|
31
32
|
itemWidth,
|
|
32
33
|
indexController,
|
|
34
|
+
initialIndex,
|
|
33
35
|
loop,
|
|
34
|
-
numberOfData
|
|
35
|
-
|
|
36
|
-
translateX
|
|
37
|
-
} = params;
|
|
36
|
+
numberOfData
|
|
37
|
+
} = config;
|
|
38
38
|
const {
|
|
39
39
|
getCurrentIndex,
|
|
40
40
|
lastIndex,
|
|
41
|
-
|
|
41
|
+
notifyScrollStateHasChanged
|
|
42
42
|
} = indexController;
|
|
43
|
+
const initialOffsetX = itemWidth * initialIndex;
|
|
44
|
+
const accumulativeOffsetX = useRef(new Animated.Value(initialOffsetX)).current;
|
|
45
|
+
const animationOffsetX = useRef(new Animated.Value(0)).current;
|
|
46
|
+
const gestureTranslationX = useRef(new Animated.Value(0)).current;
|
|
47
|
+
const globalInterpolation = useMemo(() => {
|
|
48
|
+
return Animated.add(Animated.add(accumulativeOffsetX, animationOffsetX), gestureTranslationX);
|
|
49
|
+
}, []);
|
|
43
50
|
const toValueRef = useRef(0);
|
|
44
51
|
const currentOffsetRef = useRef(0);
|
|
45
52
|
const isAnimatingRef = useRef(false);
|
|
@@ -59,31 +66,37 @@ export default function usePagingAnimation(params) {
|
|
|
59
66
|
const requireNewOffset = useCallback(newOffset => {
|
|
60
67
|
const nextOffset = ensureOffsetBoundary(newOffset);
|
|
61
68
|
currentOffsetRef.current = nextOffset;
|
|
62
|
-
|
|
69
|
+
accumulativeOffsetX.setValue(nextOffset);
|
|
63
70
|
toValueRef.current = 0;
|
|
64
|
-
|
|
65
|
-
}, [ensureOffsetBoundary
|
|
71
|
+
animationOffsetX.setValue(0);
|
|
72
|
+
}, [ensureOffsetBoundary]);
|
|
66
73
|
const interruptAnimation = useCallback(() => {
|
|
67
|
-
if (
|
|
68
|
-
// Performance optimization
|
|
74
|
+
if (!isAnimatingRef.current) {
|
|
69
75
|
return;
|
|
70
76
|
}
|
|
71
77
|
|
|
72
|
-
|
|
78
|
+
animationOffsetX.stopAnimation(lastValue => {
|
|
73
79
|
isAnimatingRef.current = false;
|
|
74
80
|
const prevOffset = currentOffsetRef.current;
|
|
75
81
|
const totalOffset = prevOffset + lastValue;
|
|
76
|
-
notifyOffsetHasChanged(totalOffset);
|
|
77
82
|
requireNewOffset(totalOffset);
|
|
83
|
+
notifyScrollStateHasChanged({
|
|
84
|
+
offset: totalOffset,
|
|
85
|
+
state: 'interrupted'
|
|
86
|
+
});
|
|
78
87
|
});
|
|
79
|
-
}, [
|
|
88
|
+
}, [notifyScrollStateHasChanged, requireNewOffset]);
|
|
80
89
|
const finalizeAnimation = useCallback(() => {
|
|
81
90
|
isAnimatingRef.current = false;
|
|
82
91
|
const prevOffset = currentOffsetRef.current;
|
|
83
92
|
const toValue = toValueRef.current;
|
|
84
93
|
const totalOffset = prevOffset + toValue;
|
|
85
94
|
requireNewOffset(totalOffset);
|
|
86
|
-
|
|
95
|
+
notifyScrollStateHasChanged({
|
|
96
|
+
offset: totalOffset,
|
|
97
|
+
state: 'idle'
|
|
98
|
+
});
|
|
99
|
+
}, [notifyScrollStateHasChanged, requireNewOffset]);
|
|
87
100
|
const startPagingAnimation = useCallback((type, config) => {
|
|
88
101
|
if (isAnimatingRef.current) {
|
|
89
102
|
return;
|
|
@@ -141,9 +154,19 @@ export default function usePagingAnimation(params) {
|
|
|
141
154
|
const toValue = compensateToValue(wantedToValue, currentOffsetRef.current);
|
|
142
155
|
toValueRef.current = toValue;
|
|
143
156
|
isAnimatingRef.current = true;
|
|
157
|
+
notifyScrollStateHasChanged({
|
|
158
|
+
offset: currentOffsetRef.current + toValue,
|
|
159
|
+
state: 'dragging'
|
|
160
|
+
});
|
|
161
|
+
const lastGestureTranslationX = configWithDefaults.lastGestureTranslationX ?? 0;
|
|
162
|
+
|
|
163
|
+
if (Number.isFinite(lastGestureTranslationX)) {
|
|
164
|
+
animationOffsetX.setValue(lastGestureTranslationX);
|
|
165
|
+
gestureTranslationX.setValue(0);
|
|
166
|
+
}
|
|
144
167
|
|
|
145
168
|
if (configWithDefaults.animated) {
|
|
146
|
-
const animation = createScrollAnimation(
|
|
169
|
+
const animation = createScrollAnimation(animationOffsetX, toValue);
|
|
147
170
|
animation.start(_ref2 => {
|
|
148
171
|
let {
|
|
149
172
|
finished
|
|
@@ -156,13 +179,13 @@ export default function usePagingAnimation(params) {
|
|
|
156
179
|
} else {
|
|
157
180
|
finalizeAnimation();
|
|
158
181
|
}
|
|
159
|
-
|
|
160
|
-
notifyOffsetHasChanged(currentOffsetRef.current + toValue);
|
|
161
|
-
}, [createScrollAnimation, getCurrentIndex, finalizeAnimation, itemWidth, lastIndex, loop, notifyOffsetHasChanged]);
|
|
182
|
+
}, [createScrollAnimation, getCurrentIndex, finalizeAnimation, itemWidth, lastIndex, loop, notifyScrollStateHasChanged]);
|
|
162
183
|
return {
|
|
184
|
+
gestureTranslationX,
|
|
185
|
+
globalInterpolation,
|
|
163
186
|
interruptAnimation,
|
|
164
187
|
startPagingAnimation
|
|
165
188
|
};
|
|
166
189
|
}
|
|
167
190
|
;
|
|
168
|
-
//# sourceMappingURL=
|
|
191
|
+
//# sourceMappingURL=usePagingAnimator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useMemo","useRef","Animated","directionToValue","itemWidth","direction","toValueCompensator","toValue","currentOffset","remainder","Math","abs","halfOfItemWidth","compensateVector","usePagingAnimator","config","createScrollAnimation","indexController","initialIndex","loop","numberOfData","getCurrentIndex","lastIndex","notifyScrollStateHasChanged","initialOffsetX","accumulativeOffsetX","Value","current","animationOffsetX","gestureTranslationX","globalInterpolation","add","toValueRef","currentOffsetRef","isAnimatingRef","maxWidth","ensureOffsetBoundary","offset","isCloseToEnd","signOfOffset","requireNewOffset","newOffset","nextOffset","setValue","interruptAnimation","stopAnimation","lastValue","prevOffset","totalOffset","state","finalizeAnimation","startPagingAnimation","type","configWithDefaults","animated","currentIndex","getValueByDirectionOnAllAdjacentItemsVisible","compensateToValue","getValueByDirectionalPagingOnLoopDisabled","_config","isOriginatedFromGesture","getValueByDirectionalPaging","_configWithDefaults","getValueByIndexPaging","index","distance","wantedToValue","lastGestureTranslationX","Number","isFinite","animation","start","finished"],"sources":["usePagingAnimator.ts"],"sourcesContent":["import { useCallback, useMemo, useRef } from 'react';\nimport { Animated } from 'react-native';\nimport type {\n CreateScrollAnimation,\n DirectionalPagingAnimationConfig,\n IndexController,\n IndexPagingAnimationConfig,\n PagingAnimationConfig,\n PagingAnimationType,\n PagingDirection,\n StartPagingAnimation,\n} from '../types';\n\nexport interface PagingAnimatorConfig {\n createScrollAnimation: CreateScrollAnimation;\n itemWidth: number;\n indexController: IndexController;\n initialIndex: number;\n loop: boolean;\n numberOfData: number;\n}\n\nexport interface PagingAnimator {\n gestureTranslationX: Animated.Value;\n globalInterpolation: Animated.AnimatedInterpolation;\n interruptAnimation: () => void;\n startPagingAnimation: StartPagingAnimation;\n}\n\nfunction directionToValue(itemWidth: number) {\n return function (direction: PagingDirection): number {\n switch (direction) {\n case 'next':\n return -itemWidth;\n case 'prev':\n return itemWidth;\n case 'stay':\n return 0;\n }\n };\n}\n\nfunction toValueCompensator(itemWidth: number) {\n return function (toValue: number, currentOffset: number): number {\n const remainder = Math.abs(currentOffset % itemWidth);\n\n const halfOfItemWidth = Math.abs(itemWidth / 2);\n const compensateVector = remainder > halfOfItemWidth\n ? remainder - itemWidth\n : remainder;\n\n const direction = currentOffset > 0 ? -1 : 1;\n\n return toValue + (direction * compensateVector);\n };\n}\n\nexport default function usePagingAnimator(config: PagingAnimatorConfig): PagingAnimator {\n const {\n createScrollAnimation,\n itemWidth,\n indexController,\n initialIndex,\n loop,\n numberOfData,\n } = config;\n\n const {\n getCurrentIndex,\n lastIndex,\n notifyScrollStateHasChanged,\n } = indexController;\n\n const initialOffsetX = itemWidth * initialIndex;\n const accumulativeOffsetX = useRef(new Animated.Value(initialOffsetX)).current;\n const animationOffsetX = useRef(new Animated.Value(0)).current;\n const gestureTranslationX = useRef(new Animated.Value(0)).current;\n\n const globalInterpolation = useMemo(() => {\n return Animated.add(\n Animated.add(accumulativeOffsetX, animationOffsetX),\n gestureTranslationX,\n );\n }, []);\n\n const toValueRef = useRef<number>(0);\n const currentOffsetRef = useRef<number>(0);\n\n const isAnimatingRef = useRef<boolean>(false);\n\n const maxWidth = Math.abs(numberOfData * itemWidth);\n\n const ensureOffsetBoundary: (offset: number) => number = useCallback((offset: number) => {\n if (loop) {\n const isCloseToEnd = Math.abs(offset) >= (maxWidth - itemWidth);\n if (isCloseToEnd) {\n const signOfOffset = offset > 0 ? 1 : -1;\n return offset + (-signOfOffset * maxWidth);\n }\n }\n\n return offset % maxWidth;\n }, [itemWidth, loop, maxWidth]);\n\n const requireNewOffset = useCallback((newOffset: number) => {\n const nextOffset = ensureOffsetBoundary(newOffset);\n\n currentOffsetRef.current = nextOffset;\n accumulativeOffsetX.setValue(nextOffset);\n\n toValueRef.current = 0;\n animationOffsetX.setValue(0);\n }, [\n ensureOffsetBoundary,\n ]);\n\n const interruptAnimation = useCallback(() => {\n if (!isAnimatingRef.current) {\n return;\n }\n\n animationOffsetX.stopAnimation(lastValue => {\n isAnimatingRef.current = false;\n\n const prevOffset = currentOffsetRef.current;\n const totalOffset = prevOffset + lastValue;\n\n requireNewOffset(totalOffset);\n\n notifyScrollStateHasChanged({ offset: totalOffset, state: 'interrupted' });\n });\n }, [\n notifyScrollStateHasChanged,\n requireNewOffset,\n ]);\n\n const finalizeAnimation = useCallback(() => {\n isAnimatingRef.current = false;\n\n const prevOffset = currentOffsetRef.current;\n const toValue = toValueRef.current;\n const totalOffset = prevOffset + toValue;\n\n requireNewOffset(totalOffset);\n\n notifyScrollStateHasChanged({ offset: totalOffset, state: 'idle' });\n }, [\n notifyScrollStateHasChanged,\n requireNewOffset,\n ]);\n\n const startPagingAnimation = useCallback((type: PagingAnimationType, config: PagingAnimationConfig) => {\n if (isAnimatingRef.current) {\n return;\n }\n\n const configWithDefaults: PagingAnimationConfig = {\n animated: true,\n ...config,\n };\n\n const currentIndex = getCurrentIndex();\n\n const getValueByDirectionOnAllAdjacentItemsVisible = directionToValue(itemWidth);\n const compensateToValue = toValueCompensator(itemWidth);\n\n const getValueByDirectionalPagingOnLoopDisabled = (_config: DirectionalPagingAnimationConfig): number => {\n const { direction, isOriginatedFromGesture } = _config;\n\n if (currentIndex === 0 && direction === 'prev') {\n return isOriginatedFromGesture\n ? getValueByDirectionOnAllAdjacentItemsVisible('stay')\n : -lastIndex * itemWidth; // last position\n } else if (currentIndex === lastIndex && direction === 'next') {\n return isOriginatedFromGesture\n ? getValueByDirectionOnAllAdjacentItemsVisible('stay')\n : lastIndex * itemWidth; // first position\n }\n return getValueByDirectionOnAllAdjacentItemsVisible(direction);\n };\n\n const getValueByDirectionalPaging = (_config: DirectionalPagingAnimationConfig): number => {\n const _configWithDefaults: DirectionalPagingAnimationConfig = {\n isOriginatedFromGesture: false,\n ..._config,\n };\n\n return loop\n ? getValueByDirectionOnAllAdjacentItemsVisible(_configWithDefaults.direction)\n : getValueByDirectionalPagingOnLoopDisabled(_configWithDefaults);\n };\n\n const getValueByIndexPaging = ({ index }: IndexPagingAnimationConfig): number => {\n if (index < 0 || index > lastIndex || index === currentIndex) {\n // no animation if index is invalid or equals to current index\n return 0;\n }\n\n const distance = Math.abs(currentIndex - index) * itemWidth;\n const direction = index > currentIndex ? -1 : 1;\n\n return distance * direction;\n };\n\n const wantedToValue = type === 'directional'\n // @ts-ignore\n ? getValueByDirectionalPaging(configWithDefaults)\n // @ts-ignore\n : getValueByIndexPaging(configWithDefaults);\n\n const toValue = compensateToValue(wantedToValue, currentOffsetRef.current);\n\n toValueRef.current = toValue;\n isAnimatingRef.current = true;\n\n notifyScrollStateHasChanged({\n offset: currentOffsetRef.current + toValue,\n state: 'dragging',\n });\n\n const lastGestureTranslationX: number = configWithDefaults.lastGestureTranslationX ?? 0;\n if (Number.isFinite(lastGestureTranslationX)) {\n animationOffsetX.setValue(lastGestureTranslationX);\n gestureTranslationX.setValue(0);\n }\n\n if (configWithDefaults.animated) {\n const animation = createScrollAnimation(animationOffsetX, toValue);\n\n animation.start(({ finished }) => {\n if (finished) {\n finalizeAnimation();\n }\n });\n } else {\n finalizeAnimation();\n }\n }, [\n createScrollAnimation,\n getCurrentIndex,\n finalizeAnimation,\n itemWidth,\n lastIndex,\n loop,\n notifyScrollStateHasChanged,\n ]);\n\n return {\n gestureTranslationX,\n globalInterpolation,\n interruptAnimation,\n startPagingAnimation,\n };\n};\n"],"mappings":"AAAA,SAASA,WAAT,EAAsBC,OAAtB,EAA+BC,MAA/B,QAA6C,OAA7C;AACA,SAASC,QAAT,QAAyB,cAAzB;;AA4BA,SAASC,gBAAT,CAA0BC,SAA1B,EAA6C;EACzC,OAAO,UAAUC,SAAV,EAA8C;IACjD,QAAQA,SAAR;MACI,KAAK,MAAL;QACI,OAAO,CAACD,SAAR;;MACJ,KAAK,MAAL;QACI,OAAOA,SAAP;;MACJ,KAAK,MAAL;QACI,OAAO,CAAP;IANR;EAQH,CATD;AAUH;;AAED,SAASE,kBAAT,CAA4BF,SAA5B,EAA+C;EAC3C,OAAO,UAAUG,OAAV,EAA2BC,aAA3B,EAA0D;IAC7D,MAAMC,SAAS,GAAGC,IAAI,CAACC,GAAL,CAASH,aAAa,GAAGJ,SAAzB,CAAlB;IAEA,MAAMQ,eAAe,GAAGF,IAAI,CAACC,GAAL,CAASP,SAAS,GAAG,CAArB,CAAxB;IACA,MAAMS,gBAAgB,GAAGJ,SAAS,GAAGG,eAAZ,GACnBH,SAAS,GAAGL,SADO,GAEnBK,SAFN;IAIA,MAAMJ,SAAS,GAAGG,aAAa,GAAG,CAAhB,GAAoB,CAAC,CAArB,GAAyB,CAA3C;IAEA,O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