add skipInactive option
Skip inactive time is an important and useful feature. We consider user interaction events as active, and check next user interaction event after apply incremental snapshot. If next user interaction event has a time gap larger than the threshold, we will set a dynamic speed value which will skip the inactive time interval in about 5 seconds.
This commit is contained in:
@@ -28,15 +28,15 @@ export default class Timer {
|
||||
public start() {
|
||||
this.actions.sort((a1, a2) => a1.delay - a2.delay);
|
||||
let delayed = 0;
|
||||
const start = performance.now();
|
||||
let lastTimestamp = performance.now();
|
||||
const { actions, config } = this;
|
||||
const self = this;
|
||||
function check(time: number) {
|
||||
delayed = time - start;
|
||||
delayed += (time - lastTimestamp) * config.speed;
|
||||
lastTimestamp = time;
|
||||
while (actions.length) {
|
||||
const action = actions[0];
|
||||
const delayNeeded = action.delay / config.speed;
|
||||
if (delayed >= delayNeeded) {
|
||||
if (delayed >= action.delay) {
|
||||
actions.shift();
|
||||
action.doAction();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user