resume with time offset when after wait stylesheet load

This commit is contained in:
Yanzhen Yu
2019-04-09 16:57:20 +08:00
parent dcc7b925fe
commit faed623986
4 changed files with 6 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "rrweb", "name": "rrweb",
"version": "0.7.10", "version": "0.7.11",
"description": "record and replay the web", "description": "record and replay the web",
"scripts": { "scripts": {
"test": "npm run bundle:browser && cross-env TS_NODE_CACHE=false TS_NODE_FILES=true mocha -r ts-node/register test/**/*.test.ts", "test": "npm run bundle:browser && cross-env TS_NODE_CACHE=false TS_NODE_FILES=true mocha -r ts-node/register test/**/*.test.ts",

View File

@@ -156,7 +156,7 @@ function initMutationObserver(
: mirror.getId(n.previousSibling as INode), : mirror.getId(n.previousSibling as INode),
nextId: !n.nextSibling nextId: !n.nextSibling
? n.nextSibling ? n.nextSibling
: mirror.getId(n.nextSibling as INode), : mirror.getId((n.nextSibling as unknown) as INode),
node: serializeNodeWithId(n, document, mirror.map, blockClass, true)!, node: serializeNodeWithId(n, document, mirror.map, blockClass, true)!,
}); });
} else { } else {

View File

@@ -302,7 +302,7 @@ export class Replayer {
this.pause(); this.pause();
this.emitter.emit(ReplayerEvents.LoadStylesheetStart); this.emitter.emit(ReplayerEvents.LoadStylesheetStart);
timer = window.setTimeout(() => { timer = window.setTimeout(() => {
this.resume(); this.resume(this.timer.timeOffset);
// mark timer was called // mark timer was called
timer = -1; timer = -1;
}, this.config.loadTimeout); }, this.config.loadTimeout);
@@ -311,7 +311,7 @@ export class Replayer {
css.addEventListener('load', () => { css.addEventListener('load', () => {
unloadSheets.delete(css); unloadSheets.delete(css);
if (unloadSheets.size === 0 && timer !== -1) { if (unloadSheets.size === 0 && timer !== -1) {
this.resume(); this.resume(this.timer.timeOffset);
this.emitter.emit(ReplayerEvents.LoadStylesheetEnd); this.emitter.emit(ReplayerEvents.LoadStylesheetEnd);
if (timer) { if (timer) {
window.clearTimeout(timer); window.clearTimeout(timer);

3
typings/types.d.ts vendored
View File

@@ -214,6 +214,7 @@ export declare enum ReplayerEvents {
LoadStylesheetStart = "load-stylesheet-start", LoadStylesheetStart = "load-stylesheet-start",
LoadStylesheetEnd = "load-stylesheet-end", LoadStylesheetEnd = "load-stylesheet-end",
SkipStart = "skip-start", SkipStart = "skip-start",
SkipEnd = "skip-end" SkipEnd = "skip-end",
MouseInteraction = "mouse-interaction"
} }
export {}; export {};