feat(@vant/use): add useCountDown

This commit is contained in:
chenjiahan
2020-10-06 09:41:12 +08:00
parent 8e5c8f2f89
commit 6334d6a7a7
10 changed files with 191 additions and 10 deletions
+4 -1
View File
@@ -6,7 +6,6 @@ import {
onBeforeUnmount,
} from 'vue';
import { raf, cancelRaf } from '../utils';
import { isSameSecond } from './utils';
export type CurrentTime = {
days: number;
@@ -46,6 +45,10 @@ export function parseTime(time: number): CurrentTime {
};
}
function isSameSecond(time1: number, time2: number): boolean {
return Math.floor(time1 / 1000) === Math.floor(time2 / 1000);
}
export function useCountDown(options: UseCountDownOptions) {
let rafId: number;
let endTime: number;
-4
View File
@@ -43,7 +43,3 @@ export function parseFormat(format: string, currentTime: CurrentTime): string {
return format;
}
export function isSameSecond(time1: number, time2: number): boolean {
return Math.floor(time1 / 1000) === Math.floor(time2 / 1000);
}