tangled
alpha
login
or
join now
flo-bit.dev
/
blento
22
fork
atom
your personal website on atproto - mirror
blento.app
22
fork
atom
overview
issues
1
pulls
pipelines
commit (working version)
Florian
1 month ago
7ac0af09
5399f15e
+37
-13
2 changed files
expand all
collapse all
unified
split
src
lib
layout.ts
website
EditableWebsite.svelte
+13
-11
src/lib/layout.ts
···
66
66
items: Item[],
67
67
item: Item,
68
68
mobile: boolean = false,
69
69
-
skipCompact: boolean = false
69
69
+
skipCompact: boolean = false,
70
70
+
originalPos?: { x: number; y: number }
70
71
) {
71
72
if (mobile) item.mobileX = clamp(item.mobileX, 0, COLUMNS - item.mobileW);
72
73
else item.x = clamp(item.x, 0, COLUMNS - item.w);
74
74
+
75
75
+
const targetX = mobile ? item.mobileX : item.x;
76
76
+
const targetY = mobile ? item.mobileY : item.y;
73
77
74
78
let layout = toLayout(items, mobile);
75
79
···
80
84
return;
81
85
}
82
86
83
83
-
layout = moveElement(
84
84
-
layout,
85
85
-
movedLayoutItem,
86
86
-
movedLayoutItem.x,
87
87
-
movedLayoutItem.y,
88
88
-
true,
89
89
-
false,
90
90
-
'vertical',
91
91
-
COLUMNS
92
92
-
);
87
87
+
// If we know the original position, set it on the layout item so
88
88
+
// moveElement can detect direction and push items properly.
89
89
+
if (originalPos) {
90
90
+
movedLayoutItem.x = originalPos.x;
91
91
+
movedLayoutItem.y = originalPos.y;
92
92
+
}
93
93
+
94
94
+
layout = moveElement(layout, movedLayoutItem, targetX, targetY, true, false, 'vertical', COLUMNS);
93
95
94
96
if (!skipCompact) layout = verticalCompactor.compact(layout, COLUMNS) as LayoutItem[];
95
97
+24
-2
src/lib/website/EditableWebsite.svelte
···
829
829
}
830
830
}
831
831
832
832
-
fixCollisions(items, activeDragElement.item, isMobile);
832
832
+
fixCollisions(
833
833
+
items,
834
834
+
activeDragElement.item,
835
835
+
isMobile,
836
836
+
false,
837
837
+
draggedOrigPos
838
838
+
? {
839
839
+
x: isMobile ? draggedOrigPos.mobileX : draggedOrigPos.x,
840
840
+
y: isMobile ? draggedOrigPos.mobileY : draggedOrigPos.y
841
841
+
}
842
842
+
: undefined
843
843
+
);
833
844
}
834
845
835
846
function touchEnd() {
···
1376
1387
}
1377
1388
1378
1389
// Now fix collisions (with compacting)
1379
1379
-
fixCollisions(items, activeDragElement.item, isMobile);
1390
1390
+
fixCollisions(
1391
1391
+
items,
1392
1392
+
activeDragElement.item,
1393
1393
+
isMobile,
1394
1394
+
false,
1395
1395
+
draggedOrigPos
1396
1396
+
? {
1397
1397
+
x: isMobile ? draggedOrigPos.mobileX : draggedOrigPos.x,
1398
1398
+
y: isMobile ? draggedOrigPos.mobileY : draggedOrigPos.y
1399
1399
+
}
1400
1400
+
: undefined
1401
1401
+
);
1380
1402
}
1381
1403
}}
1382
1404
ondragend={async (e) => {