0

I have this 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;
    })
}

Which works, except when in a background tab (at least in Safari)

How can I make this timer work, even in the background?

baao
  • 71,625
  • 17
  • 143
  • 203
Ben Aubin
  • 5,542
  • 2
  • 34
  • 54

0 Answers0