fix scroll value and record viewport when loaded

This commit is contained in:
Yanzhen Yu
2018-10-12 13:08:03 +08:00
parent c07cce74bf
commit 85a56d2047
4 changed files with 41 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
import { snapshot } from 'rrweb-snapshot';
import initObservers from './observer';
import { mirror, on } from '../utils';
import { mirror, on, getWindowWidth, getWindowHeight } from '../utils';
import {
EventType,
event,
@@ -36,7 +36,12 @@ function record(options: recordOptions = {}) {
on(
'load',
() => {
emit(wrapEvent({ type: EventType.Load, data: {} }));
emit(
wrapEvent({
type: EventType.Load,
data: { width: getWindowWidth(), height: getWindowHeight() },
}),
);
const [node, idNodeMap] = snapshot(document);
if (!node) {
return console.warn('Failed to snapshot the document');