I have a timer running in my app and i also have a part where i warn the user about something using a confirm dialog pop up. I noticed my timer script pauses any time the confirm box pops up and continues when the confirm box goes off.
Here is my timer script;
startCountDown(seconds){
this.counter = seconds;
this.interval = setInterval(() => {
this.remainingTime = this.counter;
this.counter--;
if (this.counter < 0 ) {
clearInterval(this.interval);
}
}, 1000);
}
If a confirm box is called like this:
if ( confirm("Do you wish to continue") )
the script pauses and continues when the confirm box goes away. I am aware this is the normal way it should function but i was thinking there would be a way to prevent the pop up from pausing the timer script. Any help would be appreciated. Thanks.
您是否尝试过将计时器代码移至服务类并从那里调用方法,由于服务在后台运行,因此它与组件文件中的执行无关,因此即使调用了模式弹出窗口,时间也将继续运行。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.