From 6d415e2cd7e86053cc2c832e43cca373ddb9dbad Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Fri, 6 Sep 2019 00:42:26 -0500 Subject: [PATCH] Fix trainercard alignment Clicking on a user with a very large trainercard (generally, a bot in a lot of rooms) would often push the trainercard offscreen even if it fit, or push the trainercard to unscrollable areas. With this change, the trainercard will no longer go offscreen unless it doesn't fit, and if it doesn't fit, it will always be scrollable. --- src/panels.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/panels.tsx b/src/panels.tsx index 366150803..74a9d29e6 100644 --- a/src/panels.tsx +++ b/src/panels.tsx @@ -400,8 +400,10 @@ class PSMain extends preact.Component { if (availableHeight > offset.top + height + 5 && (offset.top < availableHeight * 2 / 3 || offset.top + 200 < availableHeight)) { style.top = offset.top; - } else { + } else if (offset.top + sourceHeight >= height) { style.bottom = Math.max(availableHeight - offset.top - sourceHeight, 0); + } else { + style.top = Math.max(0, availableHeight - height); } let offsetLeft = offset.left + sourceWidth; if (offsetLeft + width > document.documentElement.clientWidth) {