tangled
alpha
login
or
join now
flo-bit.dev
/
blento
your personal website on atproto - mirror
blento.app
20
fork
atom
overview
issues
pulls
pipelines
fall trough fix
polijn.tngl.sh
1 week ago
dbcafa86
0ac11b47
+24
1 changed file
expand all
collapse all
unified
split
src
lib
helper.ts
+24
src/lib/helper.ts
···
57
57
const pushDownCascade = (target: Item, blocker: Item) => {
58
58
// Keep x fixed always when pushing down
59
59
const fixedX = mobile ? target.mobileX : target.x;
60
60
+
const prevY = mobile ? target.mobileY : target.y;
60
61
61
62
// We need target to move just below `blocker`
62
63
const desiredY = mobile ? blocker.mobileY + blocker.mobileH : blocker.y + blocker.h;
63
64
if (!mobile && target.y < desiredY) target.y = desiredY;
64
65
if (mobile && target.mobileY < desiredY) target.mobileY = desiredY;
66
66
+
67
67
+
const newY = mobile ? target.mobileY : target.y;
68
68
+
const targetH = mobile ? target.mobileH : target.h;
69
69
+
70
70
+
// fall trough fix
71
71
+
if (newY > prevY) {
72
72
+
const prevBottom = prevY + targetH;
73
73
+
const newBottom = newY + targetH;
74
74
+
for (const it of items) {
75
75
+
if (it === target || it === movedItem || it === blocker) continue;
76
76
+
const itY = mobile ? it.mobileY : it.y;
77
77
+
const itH = mobile ? it.mobileH : it.h;
78
78
+
const itBottom = itY + itH;
79
79
+
if (itBottom <= prevBottom || itY >= newBottom) continue;
80
80
+
// horizontal overlap check
81
81
+
const hOverlap = mobile
82
82
+
? target.mobileX < it.mobileX + it.mobileW && target.mobileX + target.mobileW > it.mobileX
83
83
+
: target.x < it.x + it.w && target.x + target.w > it.x;
84
84
+
if (hOverlap) {
85
85
+
pushDownCascade(it, target);
86
86
+
}
87
87
+
}
88
88
+
}
65
89
66
90
// Now resolve any collisions that creates by pushing those items down first
67
91
// Repeat until target is clean.