From 41d7bfa8f065b36fa3528e8d77b13b41156b3d4b Mon Sep 17 00:00:00 2001 From: Grace Kind Date: Fri, 24 Jul 2026 22:46:48 -0500 Subject: [PATCH] Update max size logic --- package.json | 2 +- src/js/dragHelpers.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9e1bc0c6..84807a84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "impro", - "version": "0.18.77", + "version": "0.18.78", "type": "module", "scripts": { "start": "rm -rf \"${BUILD_DIR:-build}\" && NODE_ENV=development eleventy --serve", diff --git a/src/js/dragHelpers.js b/src/js/dragHelpers.js index fca912c5..5a1e9f07 100644 --- a/src/js/dragHelpers.js +++ b/src/js/dragHelpers.js @@ -201,6 +201,7 @@ export function enableDragToDismiss( const { axis, sign } = DIRECTION_TO_AXIS_SIGN[direction]; const transformFn = axis === "y" ? "translateY" : "translateX"; const sizeProp = axis === "y" ? "height" : "width"; + const maxSizeProp = axis === "y" ? "maxHeight" : "maxWidth"; let initialSize = 0; let caretRestoreTimer = null; @@ -218,7 +219,10 @@ export function enableDragToDismiss( const clearInlineStyles = () => { target.style.transform = ""; - if (allowOppositeStretch) target.style[sizeProp] = ""; + if (allowOppositeStretch) { + target.style[sizeProp] = ""; + target.style[maxSizeProp] = ""; + } }; const handle = trackDrag(target, { @@ -231,6 +235,12 @@ export function enableDragToDismiss( clearTimeout(caretRestoreTimer); target.style.transition = "none"; initialSize = target.getBoundingClientRect()[sizeProp]; + if (allowOppositeStretch) { + // Pin the size inline before lifting the max, so the element doesn't + // snap to its natural size for a frame when the CSS cap was clamping it. + target.style[sizeProp] = `${initialSize}px`; + target.style[maxSizeProp] = "none"; + } if (hideCaretDuringDrag) target.style.caretColor = "transparent"; onDragStart(); }, @@ -289,6 +299,7 @@ export function enableDragToDismiss( target.style.transform = ""; target.style.transition = ""; target.style[sizeProp] = ""; + target.style[maxSizeProp] = ""; target.style.caretColor = ""; }; -- 2.51.2