This commit is contained in:
Jean Pierre
2023-12-15 16:03:37 +00:00
parent 81a4d860c5
commit 9f995c6ff8
3 changed files with 11 additions and 30 deletions
+2 -9
View File
@@ -3,7 +3,6 @@
* @license MIT
*/
import { IDisposable } from 'common/Types';
import { RenderDebouncer } from 'browser/RenderDebouncer';
import { IRenderDebouncerWithCallback } from 'browser/Types';
import { IRenderDimensions, IRenderer } from 'browser/renderer/shared/Types';
@@ -25,7 +24,7 @@ export class RenderService extends Disposable implements IRenderService {
private _renderer: MutableDisposable<IRenderer> = this.register(new MutableDisposable());
private _renderDebouncer: IRenderDebouncerWithCallback;
private _pausedResizeTask = new DebouncedIdleTask();
private _observerDisposable: IDisposable | undefined;
private _observerDisposable = this.register(new MutableDisposable());
private _isPaused: boolean = false;
private _needsFullRefresh: boolean = false;
@@ -110,11 +109,10 @@ export class RenderService extends Disposable implements IRenderService {
private _registerIntersectionObserver(w: Window & typeof globalThis, screenElement: HTMLElement): void {
// Detect whether IntersectionObserver is detected and enable renderer pause
// and resume based on terminal visibility if so
this._observerDisposable?.dispose();
if ('IntersectionObserver' in w) {
const observer = new w.IntersectionObserver(e => this._handleIntersectionChange(e[e.length - 1]), { threshold: 0 });
observer.observe(screenElement);
this._observerDisposable = toDisposable(() => observer.disconnect());
this._observerDisposable.value = toDisposable(() => observer.disconnect());
}
}
@@ -283,9 +281,4 @@ export class RenderService extends Disposable implements IRenderService {
public clear(): void {
this._renderer.value?.clear();
}
public override dispose(): void {
this._observerDisposable?.dispose();
super.dispose();
}
}