Skip to content

Commit

Permalink
feat: fix timer
Browse files Browse the repository at this point in the history
  • Loading branch information
oct16 committed Mar 16, 2020
1 parent 75a020a commit d19e960
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/player/src/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ContainerComponent } from './container'

export class PlayerComponent {
data: SnapshotData[]
delayTime = 5000
speed = 0
index = 0
frameIndex = 0
Expand Down Expand Up @@ -67,7 +68,7 @@ export class PlayerComponent {
if (currTime >= nextTime) {
this.frameIndex++

this.progress.updateTimer((endTime - nextTime) / 1000 + 1)
this.progress.updateTimer((endTime - nextTime + this.delayTime) / 1000)
const progress = (this.frameIndex / this.frames.length) * 100

if (progress - this.lastPercentage > this.getPercentInterval()) {
Expand Down Expand Up @@ -117,9 +118,8 @@ export class PlayerComponent {
this.progressState = reduxStore.getState()['progress']
const { startTime, endTime } = this.progressState

const delay = 500
const s = +startTime
const e = +endTime + delay
const e = +endTime + this.delayTime

const result: number[] = []

Expand Down
3 changes: 3 additions & 0 deletions packages/utils/src/tool.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export function secondToDate(ms: number) {
if (ms <= 0) {
ms = 0
}
const [h, m, s] = [Math.floor(ms / 3600), Math.floor((ms / 60) % 60), Math.floor(ms % 60)]

const timeStr = [h, m, s].map(i => (i <= 9 ? '0' + i : i)).join(':')
Expand Down

0 comments on commit d19e960

Please sign in to comment.