first commit
Some checks failed
Build / run (push) Has been cancelled

This commit is contained in:
maher
2025-10-29 11:42:25 +01:00
commit 703f50a09d
4595 changed files with 385164 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
// use intersection observer instead of getBoundingClientRect for better performance as this will be called in onPointerMove event
import {InteractableRect} from '../interactable-event';
import {ConnectedMouseSelectable} from './mouse-selection/use-mouse-selectable';
import {DraggableId} from './use-draggable';
import {ConnectedDroppable} from './use-droppable';
export function updateRects(
targets: Map<DraggableId, ConnectedDroppable | ConnectedMouseSelectable>
) {
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
const {width, height, left, top} = entry.boundingClientRect;
const [id, target] =
[...targets].find(
([, target]) => target.ref.current === entry.target
) || [];
if (id == null || target == null) return;
const rect: InteractableRect = {
width,
height,
left,
top,
};
targets.set(id, {...target, rect});
});
observer.disconnect();
});
[...targets.values()].forEach(target => {
if (target.ref.current) {
observer.observe(target.ref.current);
}
});
}