From 3b043fb734d59e6d03bd151811d2539a97624d4f Mon Sep 17 00:00:00 2001 From: polijn Date: Sat, 31 Jan 2026 20:51:19 +0100 Subject: [PATCH] safari drag and drop fix --- src/lib/website/EditableWebsite.svelte | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/lib/website/EditableWebsite.svelte b/src/lib/website/EditableWebsite.svelte index 67d233c..31b0d46 100644 --- a/src/lib/website/EditableWebsite.svelte +++ b/src/lib/website/EditableWebsite.svelte @@ -809,21 +809,7 @@ }} ondragend={async (e) => { e.preventDefault(); - const cell = getDragXY(e); - if (!cell) return; - - if (activeDragElement.item) { - if (isMobile) { - activeDragElement.item.mobileX = cell.x; - activeDragElement.item.mobileY = cell.y; - } else { - activeDragElement.item.x = cell.x; - activeDragElement.item.y = cell.y; - } - - // Fix collisions and compact items after drag ends - fixCollisions(items, activeDragElement.item, isMobile); - } + // safari fix activeDragElement.x = -1; activeDragElement.y = -1; activeDragElement.element = null; @@ -863,6 +849,15 @@ activeDragElement.w = item.w; activeDragElement.h = item.h; activeDragElement.item = item; + // fix for div shadow during drag and drop + const transparent = document.createElement('div'); + transparent.style.position = 'fixed'; + transparent.style.top = '-1000px'; + transparent.style.width = '1px'; + transparent.style.height = '1px'; + document.body.appendChild(transparent); + e.dataTransfer?.setDragImage(transparent, 0, 0); + requestAnimationFrame(() => transparent.remove()); // Store original positions of all items activeDragElement.originalPositions = new Map(); -- 2.51.2