@momo-kits/date-picker 0.110.1-beta.7 → 0.111.1-beta.2
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/WheelPickerItem.tsx +1 -1
- package/package.json +1 -1
- package/utils.ts +1 -40
package/WheelPickerItem.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, {FC, memo, useContext} from 'react';
|
|
2
|
-
import {Animated
|
|
2
|
+
import {Animated} from 'react-native';
|
|
3
3
|
import styles from './styles';
|
|
4
4
|
import {ApplicationContext, scaleSize} from '@momo-kits/foundation';
|
|
5
5
|
import {WheelPickerItemProps} from './types';
|
package/package.json
CHANGED
package/utils.ts
CHANGED
|
@@ -5,7 +5,7 @@ const getDaysInMonth = (
|
|
|
5
5
|
year: number,
|
|
6
6
|
month: number,
|
|
7
7
|
minDate: Date,
|
|
8
|
-
maxDate: Date
|
|
8
|
+
maxDate: Date,
|
|
9
9
|
) => {
|
|
10
10
|
const daysInMonth = new Date(year, month, 0).getDate();
|
|
11
11
|
|
|
@@ -101,44 +101,6 @@ function debounce<T extends (...args: any[]) => any>(func: T, delay: number) {
|
|
|
101
101
|
return debounced;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
function throttle<T extends (...args: any[]) => any>(func: T, delay: number) {
|
|
105
|
-
let lastCall = 0;
|
|
106
|
-
let timer: NodeJS.Timeout | null = null;
|
|
107
|
-
|
|
108
|
-
function throttled(this: ThisParameterType<T>, ...args: Parameters<T>) {
|
|
109
|
-
const now = Date.now();
|
|
110
|
-
const remaining = delay - (now - lastCall);
|
|
111
|
-
|
|
112
|
-
// If time since last call is greater than or equal to delay, call func immediately
|
|
113
|
-
if (remaining <= 0 || remaining > delay) {
|
|
114
|
-
if (timer) {
|
|
115
|
-
clearTimeout(timer);
|
|
116
|
-
timer = null;
|
|
117
|
-
}
|
|
118
|
-
lastCall = now;
|
|
119
|
-
func.apply(this, args);
|
|
120
|
-
}
|
|
121
|
-
// Otherwise, schedule a call for the remaining time, if we haven't already
|
|
122
|
-
else if (!timer) {
|
|
123
|
-
timer = setTimeout(() => {
|
|
124
|
-
lastCall = Date.now();
|
|
125
|
-
timer = null;
|
|
126
|
-
func.apply(this, args);
|
|
127
|
-
}, remaining);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
throttled.cancel = () => {
|
|
132
|
-
if (timer) {
|
|
133
|
-
clearTimeout(timer);
|
|
134
|
-
timer = null;
|
|
135
|
-
}
|
|
136
|
-
lastCall = 0;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
return throttled;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
104
|
export {
|
|
143
105
|
getDaysInMonth,
|
|
144
106
|
getMonths,
|
|
@@ -147,5 +109,4 @@ export {
|
|
|
147
109
|
getMinutes,
|
|
148
110
|
timeMode,
|
|
149
111
|
debounce,
|
|
150
|
-
throttle,
|
|
151
112
|
};
|