add scroll and viewport resize observers
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { snapshot } from 'rrweb-snapshot';
|
||||
import initObservers from './observer';
|
||||
import { mirror } from '../utils';
|
||||
import { mirror, on } from '../utils';
|
||||
import {
|
||||
EventType,
|
||||
event,
|
||||
@@ -9,14 +9,6 @@ import {
|
||||
IncrementalSource,
|
||||
} from '../types';
|
||||
|
||||
function on(
|
||||
type: string,
|
||||
fn: EventListenerOrEventListenerObject,
|
||||
target = document,
|
||||
) {
|
||||
target.addEventListener(type, fn, { capture: true, passive: true });
|
||||
}
|
||||
|
||||
function wrapEvent(e: event): eventWithTime {
|
||||
return {
|
||||
...e,
|
||||
@@ -80,6 +72,26 @@ function record(options: recordOptions) {
|
||||
},
|
||||
}),
|
||||
),
|
||||
scrollCb: p =>
|
||||
emit(
|
||||
wrapEvent({
|
||||
type: EventType.IncrementalSnapshot,
|
||||
data: {
|
||||
source: IncrementalSource.Scroll,
|
||||
...p,
|
||||
},
|
||||
}),
|
||||
),
|
||||
viewportResizeCb: d =>
|
||||
emit(
|
||||
wrapEvent({
|
||||
type: EventType.IncrementalSnapshot,
|
||||
data: {
|
||||
source: IncrementalSource.ViewportResize,
|
||||
...d,
|
||||
},
|
||||
}),
|
||||
),
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user