···57 const pushDownCascade = (target: Item, blocker: Item) => {
58 // Keep x fixed always when pushing down
59 const fixedX = mobile ? target.mobileX : target.x;
06061 // We need target to move just below `blocker`
62 const desiredY = mobile ? blocker.mobileY + blocker.mobileH : blocker.y + blocker.h;
63 if (!mobile && target.y < desiredY) target.y = desiredY;
64 if (mobile && target.mobileY < desiredY) target.mobileY = desiredY;
000000000000000000000006566 // Now resolve any collisions that creates by pushing those items down first
67 // Repeat until target is clean.
···57 const pushDownCascade = (target: Item, blocker: Item) => {
58 // Keep x fixed always when pushing down
59 const fixedX = mobile ? target.mobileX : target.x;
60+ const prevY = mobile ? target.mobileY : target.y;
6162 // We need target to move just below `blocker`
63 const desiredY = mobile ? blocker.mobileY + blocker.mobileH : blocker.y + blocker.h;
64 if (!mobile && target.y < desiredY) target.y = desiredY;
65 if (mobile && target.mobileY < desiredY) target.mobileY = desiredY;
66+67+ const newY = mobile ? target.mobileY : target.y;
68+ const targetH = mobile ? target.mobileH : target.h;
69+70+ // fall trough fix
71+ if (newY > prevY) {
72+ const prevBottom = prevY + targetH;
73+ const newBottom = newY + targetH;
74+ for (const it of items) {
75+ if (it === target || it === movedItem || it === blocker) continue;
76+ const itY = mobile ? it.mobileY : it.y;
77+ const itH = mobile ? it.mobileH : it.h;
78+ const itBottom = itY + itH;
79+ if (itBottom <= prevBottom || itY >= newBottom) continue;
80+ // horizontal overlap check
81+ const hOverlap = mobile
82+ ? target.mobileX < it.mobileX + it.mobileW && target.mobileX + target.mobileW > it.mobileX
83+ : target.x < it.x + it.w && target.x + target.w > it.x;
84+ if (hOverlap) {
85+ pushDownCascade(it, target);
86+ }
87+ }
88+ }
8990 // Now resolve any collisions that creates by pushing those items down first
91 // Repeat until target is clean.