close #84 set mousemoveData's source by event source
This commit is contained in:
@@ -132,12 +132,12 @@ function record(options: recordOptions = {}): listenerHandler | undefined {
|
||||
},
|
||||
}),
|
||||
),
|
||||
mousemoveCb: positions =>
|
||||
mousemoveCb: (positions, source) =>
|
||||
wrappedEmit(
|
||||
wrapEvent({
|
||||
type: EventType.IncrementalSnapshot,
|
||||
data: {
|
||||
source: IncrementalSource.MouseMove,
|
||||
source,
|
||||
positions,
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
textCursor,
|
||||
attributeCursor,
|
||||
blockClass,
|
||||
IncrementalSource,
|
||||
} from '../types';
|
||||
import { deepDelete, isParentRemoved, isAncestorInSet } from './collection';
|
||||
|
||||
@@ -275,13 +276,14 @@ function initMutationObserver(
|
||||
function initMoveObserver(cb: mousemoveCallBack): listenerHandler {
|
||||
let positions: mousePosition[] = [];
|
||||
let timeBaseline: number | null;
|
||||
const wrappedCb = throttle(() => {
|
||||
const wrappedCb = throttle((isTouch: boolean) => {
|
||||
const totalOffset = Date.now() - timeBaseline!;
|
||||
cb(
|
||||
positions.map(p => {
|
||||
p.timeOffset -= totalOffset;
|
||||
return p;
|
||||
}),
|
||||
isTouch ? IncrementalSource.TouchMove : IncrementalSource.MouseMove,
|
||||
);
|
||||
positions = [];
|
||||
timeBaseline = null;
|
||||
@@ -301,7 +303,7 @@ function initMoveObserver(cb: mousemoveCallBack): listenerHandler {
|
||||
id: mirror.getId(target as INode),
|
||||
timeOffset: Date.now() - timeBaseline,
|
||||
});
|
||||
wrappedCb();
|
||||
wrappedCb(isTouchEvent(evt));
|
||||
},
|
||||
50,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user