From f5a5a79a828e3d2339f819d88227d1bfd8935720 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Tue, 24 Sep 2024 20:58:32 +0700 Subject: [PATCH] Check offscreen element in isElementVisible() --- dist/better-xcloud.user.js | 2 +- src/utils/html.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/better-xcloud.user.js b/dist/better-xcloud.user.js index af18e0e..f6b1344 100644 --- a/dist/better-xcloud.user.js +++ b/dist/better-xcloud.user.js @@ -237,7 +237,7 @@ function escapeHtml(html) { } function isElementVisible($elm) { const rect = $elm.getBoundingClientRect(); - return !!rect.width && !!rect.height; + return (rect.x >= 0 || rect.y >= 0) && !!rect.width && !!rect.height; } function removeChildElements($parent) { while ($parent.firstElementChild) diff --git a/src/utils/html.ts b/src/utils/html.ts index 3e921b3..8b02362 100644 --- a/src/utils/html.ts +++ b/src/utils/html.ts @@ -163,7 +163,7 @@ export function escapeHtml(html: string): string { export function isElementVisible($elm: HTMLElement): boolean { const rect = $elm.getBoundingClientRect(); - return !!rect.width && !!rect.height; + return (rect.x >= 0 || rect.y >= 0) && !!rect.width && !!rect.height; } export const CTN = document.createTextNode.bind(document);