Skip to content

Commit

Permalink
resolve #4 do not add action asynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardwu1 committed Nov 16, 2018
1 parent 47b0c4d commit 1ea3d71
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/replay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class Replayer {
event.data.positions = event.data.positions.map(p => {
return {
...p,
timeOffset: p.timeOffset - firstOffset,
timeOffset: p.timeOffset - firstOffset + firstTimestamp - this.baselineTime,
};
});
return firstTimestamp - this.baselineTime;
Expand Down
5 changes: 1 addition & 4 deletions src/replay/timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@ export default class Timer {
const start = performance.now();
const { actions, config } = this;
function check(time: number) {
if (actions.length === 0) {
return;
}
delayed = time - start;
while (actions.length) {
const action = actions[0];
const delayNeeded = action.delay / config.speed;
if (delayed >= delayNeeded) {
action.doAction();
actions.shift();
action.doAction();
} else {
break;
}
Expand Down

0 comments on commit 1ea3d71

Please sign in to comment.