mirror of
https://github.com/transmission/transmission.git
synced 2025-12-19 18:08:31 +00:00
refactor: alternative x/y coords to account for zoomed in browser (#6945)
* Update transmission.js * refactor: accommodate suggestions + alternative x/y coords Thanks @tearfur! Co-Authored-By: Yat Ho <46261767+tearfur@users.noreply.github.com> --------- Co-authored-by: Yat Ho <46261767+tearfur@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
@@ -240,15 +240,15 @@ export class Transmission extends EventTarget {
|
||||
const boundingElement = document.querySelector('#torrent-container');
|
||||
const bounds = boundingElement.getBoundingClientRect();
|
||||
const x = Math.min(
|
||||
this.isTouch ? event_.touches[0].clientX : event_.x,
|
||||
bounds.x + bounds.width - popup.root.clientWidth,
|
||||
this.isTouch ? event_.touches[0].pageX : event_.pageX,
|
||||
bounds.right + globalThis.scrollX - popup.root.clientWidth,
|
||||
);
|
||||
const y = Math.min(
|
||||
this.isTouch ? event_.touches[0].clientY : event_.y,
|
||||
bounds.y + bounds.height - popup.root.clientHeight,
|
||||
this.isTouch ? event_.touches[0].pageY : event_.pageY,
|
||||
bounds.bottom + globalThis.scrollY - popup.root.clientHeight,
|
||||
);
|
||||
popup.root.style.left = `${x > 0 ? x : 0}px`;
|
||||
popup.root.style.top = `${y > 0 ? y : 0}px`;
|
||||
popup.root.style.left = `${Math.max(x, 0)}px`;
|
||||
popup.root.style.top = `${Math.max(y, 0)}px`;
|
||||
event_.preventDefault();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user