[Clocks / Timers]  adding ability to pause and resume

added the alternating pause and resume timer
This commit is contained in:
DJ
2017-01-14 16:43:20 -06:00
parent 9df59522d9
commit 165bd4f638
9 changed files with 431 additions and 7 deletions

View File

@ -74,7 +74,15 @@ define(
formatKey = model.timerFormat,
actionCapability = domainObject.getCapability('action'),
actionKey = (timestamp === undefined) ?
'timer.start' : 'timer.restart';
'timer.start' : 'timer.restart';
self.paused = model.paused;
self.pausedTime = model.pausedTime;
//if paused on startup show last known position
if (self.paused && !lastTimestamp){
lastTimestamp = self.pausedTime;
}
updateFormat(formatKey);
updateTimestamp(timestamp);
@ -98,8 +106,11 @@ define(
function tick() {
var lastSign = self.signValue,
lastText = self.textValue;
lastTimestamp = now();
update();
if (!self.paused) {
lastTimestamp = now();
update();
}
// We're running in an animation frame, not in a digest cycle.
// We need to trigger a digest cycle if our displayable data
// changes.