fix(editor): replace checkVisibility (#9481)

This commit is contained in:
Flrande
2025-01-02 08:25:48 +00:00
parent 8c05c6ef5b
commit 72e343c379

View File

@@ -14,7 +14,8 @@ import { DropFlags, type DroppingType, type DropResult } from './types.js';
function getVisiblePreviousElementSibling(element: Element | null) {
if (!element) return null;
let prev = element.previousElementSibling;
while (prev && !prev.checkVisibility()) {
// https://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom
while (prev instanceof HTMLElement && prev.offsetParent === null) {
prev = prev.previousElementSibling;
}
return prev;
@@ -23,7 +24,7 @@ function getVisiblePreviousElementSibling(element: Element | null) {
function getVisibleNextElementSibling(element: Element | null) {
if (!element) return null;
let next = element.nextElementSibling;
while (next && !next.checkVisibility()) {
while (next instanceof HTMLElement && next.offsetParent === null) {
next = next.nextElementSibling;
}
return next;