@fountain-ui/lab 3.0.0-alpha.20 → 3.0.0-alpha.22
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/AnimatedY/AnimatedY.js +1 -1
- package/build/commonjs/AnimatedY/AnimatedY.js.map +1 -1
- package/build/commonjs/BottomSheet/BottomSheetNative.js +1 -1
- package/build/commonjs/BottomSheet/BottomSheetNative.js.map +1 -1
- package/build/commonjs/BottomSheet/BottomSheetWeb.js +1 -1
- package/build/commonjs/BottomSheet/BottomSheetWeb.js.map +1 -1
- package/build/commonjs/Carousel/components/ScrollViewGesture.js +22 -45
- package/build/commonjs/Carousel/components/ScrollViewGesture.js.map +1 -1
- package/build/commonjs/ComicViewer/FastScroll.js +1 -1
- package/build/commonjs/ComicViewer/FastScroll.js.map +1 -1
- package/build/commonjs/FlipCard/FlipCard.js +2 -2
- package/build/commonjs/FlipCard/FlipCard.js.map +1 -1
- package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js +1 -5
- package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
- package/build/commonjs/hooks/useUnstableToggleDisplayStyle.js +1 -1
- package/build/commonjs/hooks/useUnstableToggleDisplayStyle.js.map +1 -1
- package/build/module/AnimatedY/AnimatedY.js +1 -1
- package/build/module/AnimatedY/AnimatedY.js.map +1 -1
- package/build/module/BottomSheet/BottomSheetNative.js +1 -1
- package/build/module/BottomSheet/BottomSheetNative.js.map +1 -1
- package/build/module/BottomSheet/BottomSheetWeb.js +1 -1
- package/build/module/BottomSheet/BottomSheetWeb.js.map +1 -1
- package/build/module/Carousel/components/ScrollViewGesture.js +20 -41
- package/build/module/Carousel/components/ScrollViewGesture.js.map +1 -1
- package/build/module/ComicViewer/FastScroll.js +1 -1
- package/build/module/ComicViewer/FastScroll.js.map +1 -1
- package/build/module/FlipCard/FlipCard.js +2 -2
- package/build/module/FlipCard/FlipCard.js.map +1 -1
- package/build/module/hooks/useUnstableCollapsibleAppBar.js +1 -5
- package/build/module/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
- package/build/module/hooks/useUnstableToggleDisplayStyle.js +1 -1
- package/build/module/hooks/useUnstableToggleDisplayStyle.js.map +1 -1
- package/build/typescript/Carousel/components/ScrollViewGesture.d.ts +1 -1
- package/package.json +3 -3
- package/src/AnimatedY/AnimatedY.tsx +1 -1
- package/src/BottomSheet/BottomSheetNative.tsx +1 -1
- package/src/BottomSheet/BottomSheetWeb.tsx +1 -1
- package/src/Carousel/components/ScrollViewGesture.tsx +30 -41
- package/src/ComicViewer/FastScroll.tsx +1 -1
- package/src/FlipCard/FlipCard.tsx +2 -2
- package/src/hooks/useUnstableCollapsibleAppBar.ts +1 -5
- package/src/hooks/useUnstableToggleDisplayStyle.ts +1 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React
|
|
3
|
-
import { Animated
|
|
4
|
-
import
|
|
5
|
-
import { PanGestureHandler, State as GestureHandlerState } from 'react-native-gesture-handler';
|
|
6
|
-
import * as R from 'ramda';
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Animated } from 'react-native';
|
|
4
|
+
import { GestureDetector, Gesture } from 'react-native-gesture-handler';
|
|
7
5
|
import type { AutoplayController, PagingDirection, StartPagingAnimation } from '../types';
|
|
8
6
|
|
|
9
7
|
export interface ScrollViewGestureProps {
|
|
@@ -19,13 +17,7 @@ const SCROLL_TO_ADJACENT_TX_THRESHOLD = 80;
|
|
|
19
17
|
const SCROLL_TO_ADJACENT_VX_THRESHOLD = 1000;
|
|
20
18
|
|
|
21
19
|
const ACTIVE_OFFSET_ABS_X = 5;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const endAnimationStates: Readonly<GestureHandlerState[]> = [
|
|
25
|
-
GestureHandlerState.CANCELLED,
|
|
26
|
-
GestureHandlerState.END,
|
|
27
|
-
GestureHandlerState.FAILED,
|
|
28
|
-
];
|
|
20
|
+
const WEB_TOUCH_ACTION = 'pan-y';
|
|
29
21
|
|
|
30
22
|
function shouldScrollToAdjacent(translationX: number, velocityX: number): boolean {
|
|
31
23
|
const isSameDirection = translationX * velocityX > 0;
|
|
@@ -48,23 +40,20 @@ export default function ScrollViewGesture(props: ScrollViewGestureProps) {
|
|
|
48
40
|
|
|
49
41
|
const { pause: pauseAutoplay, resume: resumeAutoplay } = autoplayController;
|
|
50
42
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (endAnimationStates.includes(state)) {
|
|
66
|
-
const direction: PagingDirection = shouldScrollToAdjacent(translationX, velocityX)
|
|
67
|
-
? (translationX < 0 ? 'next' : 'prev')
|
|
43
|
+
const panGesture = Gesture.Pan()
|
|
44
|
+
.runOnJS(true)
|
|
45
|
+
.activeOffsetX([-ACTIVE_OFFSET_ABS_X, ACTIVE_OFFSET_ABS_X])
|
|
46
|
+
.enabled(scrollEnabled)
|
|
47
|
+
.onBegin(() => {
|
|
48
|
+
pauseAutoplay();
|
|
49
|
+
interruptAnimation();
|
|
50
|
+
})
|
|
51
|
+
.onUpdate((event) => {
|
|
52
|
+
gestureTranslationX.setValue(event.translationX);
|
|
53
|
+
})
|
|
54
|
+
.onEnd((event) => {
|
|
55
|
+
const direction: PagingDirection = shouldScrollToAdjacent(event.translationX, event.velocityX)
|
|
56
|
+
? (event.translationX < 0 ? 'next' : 'prev')
|
|
68
57
|
: 'stay';
|
|
69
58
|
|
|
70
59
|
startPagingAnimation(
|
|
@@ -72,22 +61,22 @@ export default function ScrollViewGesture(props: ScrollViewGestureProps) {
|
|
|
72
61
|
{
|
|
73
62
|
direction: direction,
|
|
74
63
|
isOriginatedFromGesture: true,
|
|
75
|
-
lastGestureTranslationX: translationX,
|
|
64
|
+
lastGestureTranslationX: event.translationX,
|
|
76
65
|
},
|
|
77
66
|
);
|
|
78
67
|
|
|
79
68
|
resumeAutoplay();
|
|
80
|
-
}
|
|
81
|
-
|
|
69
|
+
})
|
|
70
|
+
.onFinalize(() => {
|
|
71
|
+
resumeAutoplay();
|
|
72
|
+
});
|
|
82
73
|
|
|
83
74
|
return (
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
onHandlerStateChange={handleHandlerStateChange}
|
|
91
|
-
/>
|
|
75
|
+
<GestureDetector
|
|
76
|
+
touchAction={WEB_TOUCH_ACTION}
|
|
77
|
+
gesture={panGesture}
|
|
78
|
+
>
|
|
79
|
+
{children}
|
|
80
|
+
</GestureDetector>
|
|
92
81
|
);
|
|
93
82
|
}
|
|
@@ -55,7 +55,7 @@ const FastScroll = React.forwardRef((props: FastScrollProps, ref) => {
|
|
|
55
55
|
const animatedStyle = useAnimatedStyle(() => ({
|
|
56
56
|
transform: [{ translateY: indicatorOffset.value }],
|
|
57
57
|
opacity: indicatorOpacity.value,
|
|
58
|
-
}));
|
|
58
|
+
}), [indicatorOffset, indicatorOpacity]);
|
|
59
59
|
|
|
60
60
|
const position = {
|
|
61
61
|
...absolutePosition,
|
|
@@ -37,7 +37,7 @@ export default function FlipCard(props: FlipCardProps) {
|
|
|
37
37
|
{ rotateX: `${sharedAngle.value}deg` },
|
|
38
38
|
],
|
|
39
39
|
};
|
|
40
|
-
}, []);
|
|
40
|
+
}, [sharedAngle]);
|
|
41
41
|
|
|
42
42
|
const animatedBackCardStyle = useAnimatedStyle(() => {
|
|
43
43
|
return {
|
|
@@ -47,7 +47,7 @@ export default function FlipCard(props: FlipCardProps) {
|
|
|
47
47
|
{ rotateX: `${(sharedAngle.value + 180)}deg` },
|
|
48
48
|
],
|
|
49
49
|
};
|
|
50
|
-
}, []);
|
|
50
|
+
}, [sharedAngle]);
|
|
51
51
|
|
|
52
52
|
useEffect(() => {
|
|
53
53
|
sharedAngle.value = 0;
|
|
@@ -108,11 +108,7 @@ export default function useUnstableCollapsibleAppBar(userOptions: Options = defa
|
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
return {};
|
|
111
|
-
}, [
|
|
112
|
-
/**
|
|
113
|
-
* FIXME: Consider add `elevationStyle` to dependencies.
|
|
114
|
-
*/
|
|
115
|
-
]);
|
|
111
|
+
}, [translateY, overlapped, elevationStyle]);
|
|
116
112
|
|
|
117
113
|
const indexRef = useRef<number>(0);
|
|
118
114
|
const offsetsRef = useRef<Array<number>>([]);
|