From 3b0c5e52e28f031c5afbf8e8be2436a2a8fa924d Mon Sep 17 00:00:00 2001 From: trinkey Date: Thu, 13 Feb 2025 19:14:21 -0500 Subject: [PATCH] fix issue w resizing on far ends and min size for blobcat --- js/blobcat.js | 4 +++- js/index.js | 15 +++++++++------ ts/blobcat.ts | 4 +++- ts/index.ts | 23 +++++++++++++---------- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/js/blobcat.js b/js/blobcat.js index 5b2ca15..bf7767b 100644 --- a/js/blobcat.js +++ b/js/blobcat.js @@ -61,7 +61,9 @@ function createBlob() { content: "
", onDestroy: destroyBlob, height: 450, - typeable: false + typeable: false, + minWidth: 350, + minHeight: 400 }); blobcatElement = document.getElementById("blobcat"); } diff --git a/js/index.js b/js/index.js index a268a61..750aabc 100644 --- a/js/index.js +++ b/js/index.js @@ -16,15 +16,13 @@ function incrementZIndex(windowID, focus = false) { } function edgeMoveEvent(x, y, pos, windowID) { let w = WINDOWS[windowID]; - if (x - w.vars.mouseOffsetX < 0) { - x = w.vars.mouseOffsetX; - } - if (y - w.vars.mouseOffsetY < 0) { - y = w.vars.mouseOffsetY; - } if (pos == "top" || pos.startsWith("top-")) { w.height = Math.max(-(y - w.vars.mouseOffsetY - w.vars.startingPosY) + w.vars.startingHeight, w.minHeight); w.posY = Math.max(w.vars.startingHeight - w.height + w.vars.startingPosY, 0); + if (w.posY < 0) { + w.height -= w.posY; + w.posY = 0; + } } else if (pos == "bottom" || pos.startsWith("bottom-")) { w.height = Math.max(y - w.vars.mouseOffsetY - w.vars.startingPosY + w.vars.startingHeight, w.minHeight); @@ -32,8 +30,13 @@ function edgeMoveEvent(x, y, pos, windowID) { if (pos == "left" || pos.endsWith("-left")) { w.width = Math.max(-(x - w.vars.mouseOffsetX - w.vars.startingPosX) + w.vars.startingWidth, w.minWidth); w.posX = Math.max(w.vars.startingWidth - w.width + w.vars.startingPosX, 0); + if (w.posX < 0) { + w.width -= w.posX; + w.posX = 0; + } } else if (pos == "right" || pos.endsWith("-right")) { + console.log(x - w.vars.mouseOffsetX - w.vars.startingPosX + w.vars.startingWidth, w.minWidth); w.width = Math.max(x - w.vars.mouseOffsetX - w.vars.startingPosX + w.vars.startingWidth, w.minWidth); } if (w.posX + w.width + _windowPaddingX > innerWidth) { diff --git a/ts/blobcat.ts b/ts/blobcat.ts index 062b760..07f3050 100644 --- a/ts/blobcat.ts +++ b/ts/blobcat.ts @@ -80,7 +80,9 @@ function createBlob(): void { content: "
", onDestroy: destroyBlob, height: 450, - typeable: false + typeable: false, + minWidth: 350, + minHeight: 400 }); blobcatElement = document.getElementById("blobcat") as HTMLDivElement; diff --git a/ts/index.ts b/ts/index.ts index 371ee2c..77901a1 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -31,12 +31,14 @@ function incrementZIndex(windowID: string, focus: boolean=false): void { function edgeMoveEvent(x: number, y: number, pos: "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | string, windowID: string): void { let w: _winConf = WINDOWS[windowID]; - if (x - w.vars.mouseOffsetX < 0) { x = w.vars.mouseOffsetX; } - if (y - w.vars.mouseOffsetY < 0) { y = w.vars.mouseOffsetY; } - if (pos == "top" || pos.startsWith("top-")) { w.height = Math.max(-(y - w.vars.mouseOffsetY - w.vars.startingPosY) + w.vars.startingHeight, w.minHeight); w.posY = Math.max(w.vars.startingHeight - w.height + w.vars.startingPosY, 0); + + if (w.posY < 0) { + w.height -= w.posY; + w.posY = 0; + } } else if (pos == "bottom" || pos.startsWith("bottom-")) { w.height = Math.max(y - w.vars.mouseOffsetY - w.vars.startingPosY + w.vars.startingHeight, w.minHeight); } @@ -44,17 +46,18 @@ function edgeMoveEvent(x: number, y: number, pos: "top" | "bottom" | "left" | "r if (pos == "left" || pos.endsWith("-left")) { w.width = Math.max(-(x - w.vars.mouseOffsetX - w.vars.startingPosX) + w.vars.startingWidth, w.minWidth); w.posX = Math.max(w.vars.startingWidth - w.width + w.vars.startingPosX, 0); + + if (w.posX < 0) { + w.width -= w.posX; + w.posX = 0; + } } else if (pos == "right" || pos.endsWith("-right")) { + console.log(x - w.vars.mouseOffsetX - w.vars.startingPosX + w.vars.startingWidth, w.minWidth); w.width = Math.max(x - w.vars.mouseOffsetX - w.vars.startingPosX + w.vars.startingWidth, w.minWidth); } - if (w.posX + w.width + _windowPaddingX > innerWidth ) { - w.width = Math.max(innerWidth - w.posX - _windowPaddingX, w.minWidth); - } - - if (w.posY + w.height + _windowPaddingY > innerHeight) { - w.height = Math.max(innerHeight - w.posY - _windowPaddingY, w.minHeight); - } + if (w.posX + w.width + _windowPaddingX > innerWidth ) { w.width = Math.max(innerWidth - w.posX - _windowPaddingX, w.minWidth); } + if (w.posY + w.height + _windowPaddingY > innerHeight) { w.height = Math.max(innerHeight - w.posY - _windowPaddingY, w.minHeight); } w.element.style.left = `${w.posX}px`; w.element.style.top = `${w.posY}px`;