react-compound-timer
Advanced tools
Comparing version 1.1.4 to 1.1.5
import { TimeParts, Checkpoint, Direction, TimerValue, Unit } from '../../types'; | ||
export declare class TimerModel { | ||
private initialTime; | ||
private internalTime; | ||
private time; | ||
@@ -5,0 +6,0 @@ private direction; |
@@ -11,2 +11,3 @@ "use strict"; | ||
var initialTime = _a.initialTime, direction = _a.direction, timeToUpdate = _a.timeToUpdate, lastUnit = _a.lastUnit, checkpoints = _a.checkpoints, onChange = _a.onChange; | ||
this.internalTime = performance.now(); | ||
this.initialTime = initialTime; | ||
@@ -40,2 +41,3 @@ this.time = initialTime; | ||
TimerModel.prototype.setTime = function (time) { | ||
this.internalTime = performance.now(); | ||
this.time = time; | ||
@@ -79,2 +81,6 @@ }; | ||
if (callImmediately === void 0) { callImmediately = false; } | ||
if (this.timerId) { | ||
clearInterval(this.timerId); | ||
} | ||
this.internalTime = performance.now(); | ||
var repeatedFunc = function () { | ||
@@ -101,8 +107,12 @@ var oldTime = _this.time; | ||
if (this.innerState.isPlaying()) { | ||
var currentInternalTime = performance.now(); | ||
var delta = Math.abs(currentInternalTime - this.internalTime); | ||
switch (this.direction) { | ||
case 'forward': | ||
this.time = this.time + this.timeToUpdate; | ||
this.time = this.time + delta; | ||
this.internalTime = currentInternalTime; | ||
return this.time; | ||
case 'backward': { | ||
this.time = this.time - this.timeToUpdate; | ||
this.time = this.time - delta; | ||
this.internalTime = currentInternalTime; | ||
if (this.time < 0) { | ||
@@ -109,0 +119,0 @@ this.stop(); |
{ | ||
"name": "react-compound-timer", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Timer compound react component", | ||
@@ -5,0 +5,0 @@ "main": "build", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87003
48
1578