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 11, 2020
1 parent db5b1fe commit 1f946fe
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 @@ -273,6 +273,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 @@ -284,6 +285,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 @@ -489,6 +491,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 1f946fe

Please sign in to comment.