From 99e76d72f4411fe177c2bd2e74835767b9d251e0 Mon Sep 17 00:00:00 2001 From: rainbownapkin Date: Fri, 6 Dec 2024 04:35:22 -0500 Subject: [PATCH] Fixed weird bug with child clickdragger resizing --- www/js/utils.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/www/js/utils.js b/www/js/utils.js index 97f332a..45286d2 100644 --- a/www/js/utils.js +++ b/www/js/utils.js @@ -191,10 +191,10 @@ class canopyUXUtils{ //we're no longer dragging this.dragLock = false; - //if we broke the page we need to fix it + //if we fudged the numbers to keep the page from breaking 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)}vw`; + //set everything straight + this.fixCutoff(); //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; } @@ -237,21 +237,26 @@ class canopyUXUtils{ fixCutoff(standalone = true, pageBreak = document.body.scrollWidth - document.body.getBoundingClientRect().width){ - //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)}vw`; - //If we stop dragging here, let the endDrag function know to fix the pixel difference used to prevent thrashing - this.fixWidth = true; - //If we're calling this outside of drag() + //If we're calling this outside of drag() (regardless of draglock unless set otherwise) if(standalone){ + //Fix the page width, don't fudge numbers, we don't need to + this.element.style.width = `${this.calcWidth(this.element.getBoundingClientRect().width + pageBreak)}vw`; + //Tell endDrag() function not to put us in a recursive loop + this.fixWidth = false; //call end drag to finish the job this.endDrag(); + }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)}vw`; + //If we stop dragging here, let the endDrag function know to fix the pixel difference used to prevent thrashing + this.fixWidth = true; } //If we have a parent dragger if(this.parent != null){ //Make sure to fix it's cutoff too - this.parent.fixCutoff(); + this.parent.fixCutoff(!this.dragLock); } } }