Skip to content

Commit

Permalink
Merge pull request #492 from vyneer/fix/polling-frame-position
Browse files Browse the repository at this point in the history
fix: floating menu position being off during polls
  • Loading branch information
11k authored Jan 7, 2025
2 parents d348c51 + 4a6a309 commit 6591116
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions assets/chat/js/menus/ChatMenuFloating.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,15 @@ export default class ChatMenuFloating extends ChatMenu {

position(e) {
this.mousedown = false;
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 > window.innerWidth
? window.innerWidth - this.ui.width()
: 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 > window.innerHeight
? window.innerHeight - this.ui.height() - 12
: e.clientY - 12;

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

0 comments on commit 6591116

Please sign in to comment.