feat(@vant/use): add useCountDown
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user