From 2b42596d8416042d0014cf3603be7e28ede1faa8 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Sun, 15 Sep 2024 15:49:23 +0800 Subject: fix: Use correct way to set initial position of draggable blocks Otherwise, inline style 'transform' would be set to 0 when first-time dragging, 'left' and 'top' would affect draggable area. --- src/dumbymap.mjs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs index d8349c6..47c629c 100644 --- a/src/dumbymap.mjs +++ b/src/dumbymap.mjs @@ -372,18 +372,17 @@ export const generateMaps = async (container) => { } if (layout === 'overlay') { - let x = 0; - let y = 0; + let [x, y] = [0, 0]; htmlHolder.blocks.forEach(block => { // Add draggable instance block.draggableInstance = new PlainDraggable(block, { handle: block.draggablePart, snap: { x: { step: 20 }, y: { step: 20 } }, - autoScroll: false, + left: x, + top: y, }) + // Set initial postion side by side - block.style.left = `${x}px` - block.style.top = `${y}px` x += parseInt(window.getComputedStyle(block).width) + 50 if (x > window.innerWidth) { y += 200 -- cgit v1.2.3-70-g09d2