@momo-kits/calendar 0.167.1-duotest.1 → 0.167.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/MonthList.tsx +1 -34
- package/package.json +1 -1
package/MonthList.tsx
CHANGED
|
@@ -6,17 +6,11 @@ import React, {
|
|
|
6
6
|
useCallback,
|
|
7
7
|
useContext,
|
|
8
8
|
useEffect,
|
|
9
|
-
useLayoutEffect,
|
|
10
9
|
useMemo,
|
|
11
10
|
useRef,
|
|
12
11
|
useState,
|
|
13
12
|
} from 'react';
|
|
14
|
-
import {
|
|
15
|
-
FlatList,
|
|
16
|
-
NativeScrollEvent,
|
|
17
|
-
NativeSyntheticEvent,
|
|
18
|
-
Platform,
|
|
19
|
-
} from 'react-native';
|
|
13
|
+
import { FlatList, Platform } from 'react-native';
|
|
20
14
|
import { ContainerContext } from './index';
|
|
21
15
|
import LunarDateConverter from './LunarDateConverter';
|
|
22
16
|
import Month from './Month';
|
|
@@ -108,32 +102,6 @@ const MonthList = forwardRef<MonthListRef, MonthListProps>((props, ref) => {
|
|
|
108
102
|
[selectedDate, getIndexOfMonth],
|
|
109
103
|
);
|
|
110
104
|
|
|
111
|
-
// paging keeps the old pixel offset when the width changes (fold, unfold,
|
|
112
|
-
// rotation), so remember the offset and move back onto the same month
|
|
113
|
-
const scrollOffset = useRef(Math.max(currentScrollIndex, 0) * size.width);
|
|
114
|
-
const pageWidth = useRef(size.width);
|
|
115
|
-
|
|
116
|
-
useLayoutEffect(() => {
|
|
117
|
-
const previousWidth = pageWidth.current;
|
|
118
|
-
pageWidth.current = size.width;
|
|
119
|
-
if (previousWidth === size.width || previousWidth <= 0) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const page = Math.round(scrollOffset.current / previousWidth);
|
|
123
|
-
scrollOffset.current = page * size.width;
|
|
124
|
-
listRef.current?.scrollToOffset({
|
|
125
|
-
offset: scrollOffset.current,
|
|
126
|
-
animated: false,
|
|
127
|
-
});
|
|
128
|
-
}, [size.width]);
|
|
129
|
-
|
|
130
|
-
const onScroll = useCallback(
|
|
131
|
-
(e: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
132
|
-
scrollOffset.current = e.nativeEvent.contentOffset.x;
|
|
133
|
-
},
|
|
134
|
-
[],
|
|
135
|
-
);
|
|
136
|
-
|
|
137
105
|
const scrollToMonth = useCallback(
|
|
138
106
|
(month: Moment) => {
|
|
139
107
|
const idx = getIndexOfMonth(month);
|
|
@@ -243,7 +211,6 @@ const MonthList = forwardRef<MonthListRef, MonthListProps>((props, ref) => {
|
|
|
243
211
|
showsHorizontalScrollIndicator={false}
|
|
244
212
|
keyExtractor={keyExtractor}
|
|
245
213
|
onScrollToIndexFailed={() => {}}
|
|
246
|
-
onScroll={onScroll}
|
|
247
214
|
scrollEnabled
|
|
248
215
|
initialNumToRender={3}
|
|
249
216
|
maxToRenderPerBatch={MAX_RENDER_PER_BATCH}
|