move into recorder

This commit is contained in:
Simon Knott 2024-09-16 17:57:06 +02:00
parent 7c04cfbca0
commit 2e37a9e131
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 8 additions and 8 deletions

View file

@ -42,7 +42,6 @@ export type HighlightOptions = {
export class Highlight { export class Highlight {
private _glassPaneElement: HTMLElement; private _glassPaneElement: HTMLElement;
private _glassPaneShadow: ShadowRoot; private _glassPaneShadow: ShadowRoot;
private _glassPaneInterval?: NodeJS.Timeout;
private _highlightEntries: HighlightEntry[] = []; private _highlightEntries: HighlightEntry[] = [];
private _highlightOptions: HighlightOptions = {}; private _highlightOptions: HighlightOptions = {};
private _actionPointElement: HTMLElement; private _actionPointElement: HTMLElement;
@ -91,12 +90,8 @@ export class Highlight {
} }
install() { install() {
this._injectedScript.document.documentElement.appendChild(this._glassPaneElement);
this._glassPaneInterval = setInterval(() => {
if (!this._injectedScript.document.documentElement.contains(this._glassPaneElement)) if (!this._injectedScript.document.documentElement.contains(this._glassPaneElement))
this._injectedScript.document.documentElement.appendChild(this._glassPaneElement); this._injectedScript.document.documentElement.appendChild(this._glassPaneElement);
}, 500);
} }
setLanguage(language: Language) { setLanguage(language: Language) {
@ -113,7 +108,6 @@ export class Highlight {
uninstall() { uninstall() {
if (this._rafRequest) if (this._rafRequest)
cancelAnimationFrame(this._rafRequest); cancelAnimationFrame(this._rafRequest);
clearInterval(this._glassPaneInterval);
this._glassPaneElement.remove(); this._glassPaneElement.remove();
} }

View file

@ -1036,7 +1036,13 @@ export class Recorder {
addEventListener(this.document, 'focus', event => this._onFocus(event), true), addEventListener(this.document, 'focus', event => this._onFocus(event), true),
addEventListener(this.document, 'scroll', event => this._onScroll(event), true), addEventListener(this.document, 'scroll', event => this._onScroll(event), true),
]; ];
this.highlight.install(); this.highlight.install();
const recreationInterval = setInterval(() => {
this.highlight.install();
}, 500);
this._listeners.push(() => clearInterval(recreationInterval));
this.overlay?.install(); this.overlay?.install();
this.document.adoptedStyleSheets.push(this._stylesheet); this.document.adoptedStyleSheets.push(this._stylesheet);
} }