Skip to content

Commit

Permalink
Ensure animations don't continue playing when we've paused playback
Browse files Browse the repository at this point in the history
  • Loading branch information
eoghanmurray committed Nov 23, 2020
1 parent e75277c commit 91fd791
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/replay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export class Replayer {
this.service.send({ type: 'PAUSE' });
this.service.send({ type: 'PLAY', payload: { timeOffset } });
}
this.iframe.contentDocument.getElementsByTagName('html')[0].classList.remove('rrweb-paused');
this.emitter.emit(ReplayerEvents.Start);
}

Expand All @@ -287,6 +288,7 @@ export class Replayer {
this.play(timeOffset);
this.service.send({ type: 'PAUSE' });
}
this.iframe.contentDocument.getElementsByTagName('html')[0].classList.add('rrweb-paused');
this.emitter.emit(ReplayerEvents.Pause);
}

Expand Down Expand Up @@ -492,6 +494,10 @@ export class Replayer {
const injectStylesRules = getInjectStyleRules(
this.config.blockClass,
).concat(this.config.insertStyleRules);
injectStylesRules.push('html.rrweb-paused * { animation-play-state: paused !important; }');
if (!this.service.state.matches('playing')) {
this.iframe.contentDocument.getElementsByTagName('html')[0].classList.add('rrweb-paused');
}
for (let idx = 0; idx < injectStylesRules.length; idx++) {
(styleEl.sheet! as CSSStyleSheet).insertRule(injectStylesRules[idx], idx);
}
Expand Down

0 comments on commit 91fd791

Please sign in to comment.