计时器不在背景选项卡中计数

时间:2015-10-05 02:51:20

标签: javascript timer

我有这个计时器:

$scope.startTimer = function(homework) {
    homework.Timer = function() {
        if(homework.timer) {
            homework.estimatedTime.spentNow++;
            homework.calcTimes()
            $scope.$apply();
            window.setTimeout(homework.Timer, 1000);
        }
    }
    homework.timer = true;
    window.setTimeout(homework.Timer, 1000);
}
$scope.stopTimer = function(homework) {
    homework.timer = false;
    homework.stoppingTimer = true;
    homework.save().then(function() {
        homework.stoppingTimer = false;
    })
}

哪个有效,除非在后台标签中(至少在Safari中)

即使在后台,我怎样才能让这个计时器工作?

0 个答案:

没有答案