Files
klz-cables.com/.pnpm-store/v10/files/1a/9d639cccf963ef3ab4d4027aa84bc872485d4ee56dab0e1d8e41fad01ce16dbe3c4ae0734727534e82f1b4a1cbc9b915e569b39c838bc534375b12f102a6c1
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

29 lines
1.2 KiB
Plaintext

import { rectIntersection } from '@dnd-kit/core';
// If the toolbar exits the preview area, we need to reset its position
// This will prevent the toolbar from getting stuck outside the preview area
export const customCollisionDetection = ({
collisionRect,
droppableContainers,
...args
}) => {
const droppableContainer = droppableContainers.find(({
id
}) => id === 'live-preview-area');
const rectIntersectionCollisions = rectIntersection({
...args,
collisionRect,
droppableContainers: [droppableContainer]
});
// Collision detection algorithms return an array of collisions
if (rectIntersectionCollisions.length === 0) {
// The preview area is not intersecting, return early
return rectIntersectionCollisions;
}
// Compute whether the draggable element is completely contained within the preview area
const previewAreaRect = droppableContainer?.rect?.current;
const isContained = collisionRect.top >= previewAreaRect.top && collisionRect.left >= previewAreaRect.left && collisionRect.bottom <= previewAreaRect.bottom && collisionRect.right <= previewAreaRect.right;
if (isContained) {
return rectIntersectionCollisions;
}
};
//# sourceMappingURL=collisionDetection.js.map