fix last played timestamp when it is a mousemove event

This commit is contained in:
Yanzhen Yu
2020-09-20 12:37:20 +08:00
parent 2440701926
commit 9a3e1fe724

View File

@@ -6,6 +6,7 @@ import {
ReplayerEvents, ReplayerEvents,
EventType, EventType,
Emitter, Emitter,
IncrementalSource,
} from '../types'; } from '../types';
import { Timer, addDelay } from './timer'; import { Timer, addDelay } from './timer';
import { needCastInSyncMode } from '../utils'; import { needCastInSyncMode } from '../utils';
@@ -174,10 +175,19 @@ export function createPlayerService(
const actions = new Array<actionWithDelay>(); const actions = new Array<actionWithDelay>();
for (const event of neededEvents) { for (const event of neededEvents) {
let lastPlayedTimestamp = lastPlayedEvent?.timestamp;
if ( if (
lastPlayedEvent && lastPlayedEvent?.type === EventType.IncrementalSnapshot &&
lastPlayedEvent.timestamp < baselineTime && lastPlayedEvent.data.source === IncrementalSource.MouseMove
(event.timestamp <= lastPlayedEvent.timestamp || ) {
lastPlayedTimestamp =
lastPlayedEvent.timestamp +
lastPlayedEvent.data.positions[0]?.timeOffset;
}
if (
lastPlayedTimestamp &&
lastPlayedTimestamp < baselineTime &&
(event.timestamp <= lastPlayedTimestamp ||
event === lastPlayedEvent) event === lastPlayedEvent)
) { ) {
continue; continue;