Skip to content

Commit

Permalink
fix: floating menu position being off during polls
Browse files Browse the repository at this point in the history
  • Loading branch information
vyneer committed Jul 1, 2024
1 parent 19d966e commit b4d6701
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions assets/chat/js/menus/ChatMenuFloating.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,13 @@ export default class ChatMenuFloating extends ChatMenu {
const rect = this.chat.output[0].getBoundingClientRect();
// calculating floating window location (if it doesn't fit on screen, adjusting it a bit so it does)
const x =
this.ui.width() + e.clientX > rect.width
? e.clientX - rect.left + (rect.width - (this.ui.width() + e.clientX))
: e.clientX - rect.left;
this.ui.width() + e.clientX - rect.left > rect.width
? e.clientX - this.ui.width() + (rect.right - e.clientX)
: e.clientX;
const y =
this.ui.height() + e.clientY > rect.height
? e.clientY -
rect.top +
(rect.height - (this.ui.height() + e.clientY)) -
12
: e.clientY - rect.top - 12;
this.ui.height() + e.clientY - rect.top > rect.height
? e.clientY - this.ui.height() + (rect.bottom - e.clientY) - 12
: e.clientY - 12;

this.ui[0].style.left = `${x}px`;
this.ui[0].style.top = `${y}px`;
Expand Down

0 comments on commit b4d6701

Please sign in to comment.