your personal website on atproto - mirror blento.app

fall trough fix

+24
+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 + 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 + 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 + } 65 89 66 90 // Now resolve any collisions that creates by pushing those items down first 67 91 // Repeat until target is clean.