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:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent 366360c995
commit 73983e7e78
3 changed files with 61 additions and 6 deletions

View File

@@ -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 {