Skip to content

Commit

Permalink
fix(editor): replace checkVisibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Flrande committed Jan 2, 2025
1 parent ad422d2 commit 18b60e5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions blocksuite/affine/shared/src/utils/dnd/calc-drop-target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 18b60e5

Please sign in to comment.