Clamp textbox header position in window.

This commit is contained in:
Krafpy
2023-01-03 10:12:59 +01:00
parent b9c925b6e7
commit 2703c6fb41
2 changed files with 4 additions and 4 deletions

View File

@@ -37,8 +37,8 @@ export class DraggableTextbox {
};
const clamp = (x, a, b) => x < a ? a : x > b ? b : x;
document.onmouseup = () => {
left = clamp(left, 0, window.innerWidth - div.offsetWidth);
top = clamp(top, 0, window.innerHeight - div.offsetHeight);
left = clamp(left, 0, window.innerWidth - header.offsetWidth);
top = clamp(top, 0, window.innerHeight - header.offsetHeight);
setPos();
document.onmouseup = null;
document.onmousemove = null;

View File

@@ -50,8 +50,8 @@ export class DraggableTextbox {
const clamp = (x:number, a:number, b:number) => x < a ? a : x > b ? b : x;
document.onmouseup = () => {
left = clamp(left, 0, window.innerWidth - div.offsetWidth);
top = clamp(top, 0, window.innerHeight - div.offsetHeight);
left = clamp(left, 0, window.innerWidth - header.offsetWidth);
top = clamp(top, 0, window.innerHeight - header.offsetHeight);
setPos();
document.onmouseup = null;