From fa6696f9d3a29a801b0daf6f371cf3444786f5d8 Mon Sep 17 00:00:00 2001 From: rainbownapkin Date: Tue, 3 Dec 2024 05:06:40 -0500 Subject: [PATCH] Fixed channel layout bugs with click dragger. --- www/js/channel/chatPreprocessor.js | 1 - www/js/utils.js | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/www/js/channel/chatPreprocessor.js b/www/js/channel/chatPreprocessor.js index fcdb7b2..e435dd7 100644 --- a/www/js/channel/chatPreprocessor.js +++ b/www/js/channel/chatPreprocessor.js @@ -6,7 +6,6 @@ class chatPreprocessor{ //Set current chat nodes this.chatEntry = chatEntry; this.chatBody = this.chatEntry.querySelector(".chat-entry-body"); - //Split the chat body into an array of objects representing each word //We could pass this through arguments but these functions wont be very interoperable anyways since they expect a purpose-made hashtable this.splitBody(); diff --git a/www/js/utils.js b/www/js/utils.js index 438c923..98cd408 100644 --- a/www/js/utils.js +++ b/www/js/utils.js @@ -191,7 +191,7 @@ class canopyUXUtils{ //if we broke the page we need to fix it if(this.fixWidth){ //Pop the element width up just a bit to compensate for the extra pixel - this.element.style.width = `${this.calcWidth(this.element.getBoundingClientRect().width + 1)}%`; + this.element.style.width = `${this.calcWidth(this.element.getBoundingClientRect().width + 1)}vw`; //if this is true, it no longer needs to be, though it *should* be reset by the drag function by the time it matters anywho :P this.fixWidth = false; } @@ -218,12 +218,12 @@ class canopyUXUtils{ //if we're not breaking the page, or we're moving left if(pageBreak <= 0 || event.clientX < this.handle.getBoundingClientRect().left){ //Apply difference to width - this.element.style.width = `${this.calcWidth(difference)}%`; + this.element.style.width = `${this.calcWidth(difference)}vw`; //If we let go here, the width isn't breaking anything so there's nothing to fix. this.fixWidth = false; }else{ //We need to move the element back, but we can't do it all the way while we're still dragging as it will thrash - this.element.style.width = `${this.calcWidth(this.element.getBoundingClientRect().width + pageBreak - 1)}%`; + this.element.style.width = `${this.calcWidth(this.element.getBoundingClientRect().width + pageBreak - 1)}vw`; //If we stop dragging here, let the endDrag function know to fix the pixel difference used to prevent thrashing this.fixWidth = true; } @@ -231,7 +231,7 @@ class canopyUXUtils{ } calcWidth(px){ - return (px / this.element.parentElement.getBoundingClientRect().width) * 100; + return (px / window.innerWidth) * 100; } }