fix mouse move time offset may be mutated multiple times
This commit is contained in:
@@ -3,7 +3,6 @@ import * as mittProxy from 'mitt';
|
|||||||
import Timer from './timer';
|
import Timer from './timer';
|
||||||
import {
|
import {
|
||||||
EventType,
|
EventType,
|
||||||
incrementalData,
|
|
||||||
IncrementalSource,
|
IncrementalSource,
|
||||||
fullSnapshotEvent,
|
fullSnapshotEvent,
|
||||||
eventWithTime,
|
eventWithTime,
|
||||||
@@ -15,6 +14,7 @@ import {
|
|||||||
addedNodeMutation,
|
addedNodeMutation,
|
||||||
missingNode,
|
missingNode,
|
||||||
actionWithDelay,
|
actionWithDelay,
|
||||||
|
incrementalSnapshotEvent,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { mirror } from '../utils';
|
import { mirror } from '../utils';
|
||||||
import injectStyleRules from './styles/inject-style';
|
import injectStyleRules from './styles/inject-style';
|
||||||
@@ -27,7 +27,7 @@ const mitt = (mittProxy as any).default || mittProxy;
|
|||||||
const defaultConfig: playerConfig = {
|
const defaultConfig: playerConfig = {
|
||||||
speed: 1,
|
speed: 1,
|
||||||
root: document.body,
|
root: document.body,
|
||||||
loadTimeout: 10 * 1000,
|
loadTimeout: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
export class Replayer {
|
export class Replayer {
|
||||||
@@ -158,14 +158,7 @@ export class Replayer {
|
|||||||
const firstOffset = event.data.positions[0].timeOffset;
|
const firstOffset = event.data.positions[0].timeOffset;
|
||||||
// timeOffset is a negative offset to event.timestamp
|
// timeOffset is a negative offset to event.timestamp
|
||||||
const firstTimestamp = event.timestamp + firstOffset;
|
const firstTimestamp = event.timestamp + firstOffset;
|
||||||
const delay = firstTimestamp - this.baselineTime;
|
return firstTimestamp - this.baselineTime;
|
||||||
event.data.positions = event.data.positions.map(p => {
|
|
||||||
return {
|
|
||||||
...p,
|
|
||||||
timeOffset: p.timeOffset - firstOffset + delay,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
return delay;
|
|
||||||
}
|
}
|
||||||
return event.timestamp - this.baselineTime;
|
return event.timestamp - this.baselineTime;
|
||||||
}
|
}
|
||||||
@@ -191,7 +184,7 @@ export class Replayer {
|
|||||||
break;
|
break;
|
||||||
case EventType.IncrementalSnapshot:
|
case EventType.IncrementalSnapshot:
|
||||||
castFn = () => {
|
castFn = () => {
|
||||||
this.applyIncremental(event.data, isSync);
|
this.applyIncremental(event, isSync);
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -255,7 +248,11 @@ export class Replayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private applyIncremental(d: incrementalData, isSync: boolean) {
|
private applyIncremental(
|
||||||
|
e: incrementalSnapshotEvent & { timestamp: number },
|
||||||
|
isSync: boolean,
|
||||||
|
) {
|
||||||
|
const { data: d } = e;
|
||||||
switch (d.source) {
|
switch (d.source) {
|
||||||
case IncrementalSource.Mutation: {
|
case IncrementalSource.Mutation: {
|
||||||
d.removes.forEach(mutation => {
|
d.removes.forEach(mutation => {
|
||||||
@@ -351,7 +348,7 @@ export class Replayer {
|
|||||||
this.hoverElements((target as Node) as Element);
|
this.hoverElements((target as Node) as Element);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
delay: p.timeOffset,
|
delay: p.timeOffset + e.timestamp - this.baselineTime,
|
||||||
};
|
};
|
||||||
this.timer.addAction(action);
|
this.timer.addAction(action);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user