FastClickUtil.ts
556 Bytes
import systemDateTime from '@ohos.systemDateTime';
/**
* 屏蔽快速点击事件,规定时间内只触发一次
*/
export class FastClickUtil {
static MIN_DELAY_TIME = 500
static minDelayBeforeTime = 0
static async isMinDelayTime(): Promise<boolean> {
let systime = await systemDateTime.getCurrentTime();
return new Promise<boolean>((success, error) => {
let rtnvalue = systime - FastClickUtil.minDelayBeforeTime <= FastClickUtil.MIN_DELAY_TIME;
this.minDelayBeforeTime = systime;
success(rtnvalue);
})
}
}