From b4d67016117ce5570b2f6e59e29f44accf109133 Mon Sep 17 00:00:00 2001 From: vyneer Date: Mon, 1 Jul 2024 16:43:37 +0300 Subject: [PATCH 1/2] fix: floating menu position being off during polls --- assets/chat/js/menus/ChatMenuFloating.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/assets/chat/js/menus/ChatMenuFloating.js b/assets/chat/js/menus/ChatMenuFloating.js index c0ad35ea..61116de0 100644 --- a/assets/chat/js/menus/ChatMenuFloating.js +++ b/assets/chat/js/menus/ChatMenuFloating.js @@ -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`; From 4a6a309b9a9698a044e5c321ade3fc9da754f91a Mon Sep 17 00:00:00 2001 From: Farhad Jay Date: Tue, 7 Jan 2025 12:21:16 -0800 Subject: [PATCH 2/2] Simplify position calculation logic --- assets/chat/js/menus/ChatMenuFloating.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/assets/chat/js/menus/ChatMenuFloating.js b/assets/chat/js/menus/ChatMenuFloating.js index 61116de0..c28738ec 100644 --- a/assets/chat/js/menus/ChatMenuFloating.js +++ b/assets/chat/js/menus/ChatMenuFloating.js @@ -52,15 +52,14 @@ 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.left > rect.width - ? e.clientX - this.ui.width() + (rect.right - e.clientX) + this.ui.width() + e.clientX > window.innerWidth + ? window.innerWidth - this.ui.width() : e.clientX; const y = - this.ui.height() + e.clientY - rect.top > rect.height - ? e.clientY - this.ui.height() + (rect.bottom - e.clientY) - 12 + this.ui.height() + e.clientY > window.innerHeight + ? window.innerHeight - this.ui.height() - 12 : e.clientY - 12; this.ui[0].style.left = `${x}px`;