@momo-kits/date-picker 0.102.1-beta.2 → 0.102.3-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/WheelPicker.tsx +14 -11
- package/package.json +1 -1
- package/publish.sh +1 -1
package/WheelPicker.tsx
CHANGED
|
@@ -6,12 +6,12 @@ import React, {
|
|
|
6
6
|
useEffect,
|
|
7
7
|
useRef,
|
|
8
8
|
} from 'react';
|
|
9
|
-
import {Animated, View} from 'react-native';
|
|
10
|
-
import {FlatList} from 'react-native-gesture-handler';
|
|
9
|
+
import { Animated, View } from 'react-native';
|
|
10
|
+
import { FlatList } from 'react-native-gesture-handler';
|
|
11
11
|
import styles from './styles';
|
|
12
|
-
import {ApplicationContext, scaleSize} from '@momo-kits/foundation';
|
|
13
|
-
import {WheelPickerProps} from './types';
|
|
14
|
-
import {debounce} from './utils';
|
|
12
|
+
import { ApplicationContext, scaleSize } from '@momo-kits/foundation';
|
|
13
|
+
import { WheelPickerProps } from './types';
|
|
14
|
+
import { debounce } from './utils';
|
|
15
15
|
|
|
16
16
|
const AnimatedFlatList = Animated.createAnimatedComponent(FlatList);
|
|
17
17
|
const WheelPicker: FC<WheelPickerProps> = ({
|
|
@@ -21,7 +21,7 @@ const WheelPicker: FC<WheelPickerProps> = ({
|
|
|
21
21
|
onChange,
|
|
22
22
|
selectedData,
|
|
23
23
|
}) => {
|
|
24
|
-
const {theme} = useContext(ApplicationContext);
|
|
24
|
+
const { theme } = useContext(ApplicationContext);
|
|
25
25
|
const flatListRef = useRef<any>(null);
|
|
26
26
|
const scrollAnimatedValue = useRef(new Animated.Value(0)).current;
|
|
27
27
|
const active = useRef(0);
|
|
@@ -31,7 +31,7 @@ const WheelPicker: FC<WheelPickerProps> = ({
|
|
|
31
31
|
useEffect(() => {
|
|
32
32
|
scrollListener.current && clearInterval(Number(scrollListener.current));
|
|
33
33
|
scrollListener.current = scrollAnimatedValue.addListener(
|
|
34
|
-
({value}) => (active.current = value)
|
|
34
|
+
({ value }) => (active.current = value)
|
|
35
35
|
);
|
|
36
36
|
|
|
37
37
|
return () => {
|
|
@@ -74,6 +74,9 @@ const WheelPicker: FC<WheelPickerProps> = ({
|
|
|
74
74
|
if (selectedIndex > data.length - 3) {
|
|
75
75
|
selectedIndex = data.length - 3;
|
|
76
76
|
}
|
|
77
|
+
if (selectedIndex === 2) {
|
|
78
|
+
onMomentumScrollEnd()
|
|
79
|
+
}
|
|
77
80
|
flatListRef.current?.scrollToIndex({
|
|
78
81
|
index: selectedIndex - 2,
|
|
79
82
|
animated: true,
|
|
@@ -86,7 +89,7 @@ const WheelPicker: FC<WheelPickerProps> = ({
|
|
|
86
89
|
};
|
|
87
90
|
|
|
88
91
|
const ItemComponent: FC<any> = React.memo(props => {
|
|
89
|
-
const {item, opacity, scale} = props;
|
|
92
|
+
const { item, opacity, scale } = props;
|
|
90
93
|
|
|
91
94
|
return (
|
|
92
95
|
<Animated.View
|
|
@@ -99,7 +102,7 @@ const WheelPicker: FC<WheelPickerProps> = ({
|
|
|
99
102
|
<Animated.Text
|
|
100
103
|
style={{
|
|
101
104
|
fontFamily: `${theme.font}-Semibold`,
|
|
102
|
-
transform: [{scale}],
|
|
105
|
+
transform: [{ scale }],
|
|
103
106
|
fontSize: scaleSize(16),
|
|
104
107
|
lineHeight: scaleSize(22),
|
|
105
108
|
}}>
|
|
@@ -109,7 +112,7 @@ const WheelPicker: FC<WheelPickerProps> = ({
|
|
|
109
112
|
);
|
|
110
113
|
});
|
|
111
114
|
|
|
112
|
-
const renderItem = useCallback(({item, index}) => {
|
|
115
|
+
const renderItem = useCallback(({ item, index }) => {
|
|
113
116
|
const opacityAnimated = (a: number, b: number, c: number) => {
|
|
114
117
|
return {
|
|
115
118
|
inputRange: [...data.map((_: any, i: number) => i * itemSize)],
|
|
@@ -195,7 +198,7 @@ const WheelPicker: FC<WheelPickerProps> = ({
|
|
|
195
198
|
getItemLayout={getItemLayout}
|
|
196
199
|
onScrollToIndexFailed={onScrollToIndexFailed}
|
|
197
200
|
onScroll={Animated.event(
|
|
198
|
-
[{nativeEvent: {contentOffset: {y: scrollAnimatedValue}}}],
|
|
201
|
+
[{ nativeEvent: { contentOffset: { y: scrollAnimatedValue } } }],
|
|
199
202
|
{
|
|
200
203
|
useNativeDriver: true,
|
|
201
204
|
}
|
package/package.json
CHANGED
package/publish.sh
CHANGED
|
@@ -7,7 +7,7 @@ rsync -r --exclude=/dist ./* dist
|
|
|
7
7
|
cd dist
|
|
8
8
|
|
|
9
9
|
if [ "$1" == "stable" ]; then
|
|
10
|
-
npm version $(npm view @momo-kits/
|
|
10
|
+
npm version $(npm view @momo-kits/foundation@stable version)
|
|
11
11
|
npm version patch
|
|
12
12
|
npm publish --tag stable --access=public
|
|
13
13
|
elif [ "$1" == "latest" ]; then
|