mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 07:37:19 +02:00
Check offscreen element in isElementVisible()
This commit is contained in:
parent
7ec449160a
commit
f5a5a79a82
2
dist/better-xcloud.user.js
vendored
2
dist/better-xcloud.user.js
vendored
@ -237,7 +237,7 @@ function escapeHtml(html) {
|
|||||||
}
|
}
|
||||||
function isElementVisible($elm) {
|
function isElementVisible($elm) {
|
||||||
const rect = $elm.getBoundingClientRect();
|
const rect = $elm.getBoundingClientRect();
|
||||||
return !!rect.width && !!rect.height;
|
return (rect.x >= 0 || rect.y >= 0) && !!rect.width && !!rect.height;
|
||||||
}
|
}
|
||||||
function removeChildElements($parent) {
|
function removeChildElements($parent) {
|
||||||
while ($parent.firstElementChild)
|
while ($parent.firstElementChild)
|
||||||
|
@ -163,7 +163,7 @@ export function escapeHtml(html: string): string {
|
|||||||
|
|
||||||
export function isElementVisible($elm: HTMLElement): boolean {
|
export function isElementVisible($elm: HTMLElement): boolean {
|
||||||
const rect = $elm.getBoundingClientRect();
|
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);
|
export const CTN = document.createTextNode.bind(document);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user