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.
This commit is contained in:
Guangcong Luo
2019-09-06 00:42:26 -05:00
parent 10833a6c28
commit 6d415e2cd7

View File

@@ -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) {