From d5833224b1ed5eb2b063f762f9538dea5558f2f3 Mon Sep 17 00:00:00 2001 From: Chris Griffing Date: Thu, 24 Oct 2024 17:26:53 -0700 Subject: [PATCH] fix: change where maxDimensions are calculated again --- packages/shiki-magic-move/src/renderer.ts | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/shiki-magic-move/src/renderer.ts b/packages/shiki-magic-move/src/renderer.ts index a5b3ffd..609e38f 100644 --- a/packages/shiki-magic-move/src/renderer.ts +++ b/packages/shiki-magic-move/src/renderer.ts @@ -1,3 +1,7 @@ +/* eslint-disable antfu/if-newline */ +/* eslint-disable style/brace-style */ +/* eslint-disable style/indent */ +/* eslint-disable style/no-tabs */ import type { KeyedToken, KeyedTokensInfo, @@ -422,6 +426,16 @@ export class MagicMoveRenderer { // Animate the container size if (this.options.animateContainer && !this.isFirstRender) { const newRect = this.container.getBoundingClientRect() + + maxContainerDimensions.width = Math.max( + containerRect.width / scale, + newRect.width / scale, + ) + maxContainerDimensions.height = Math.max( + containerRect.height / scale, + newRect.height / scale, + ) + if ( newRect.width !== containerRect.width || newRect.height !== containerRect.height @@ -437,15 +451,6 @@ export class MagicMoveRenderer { this.container.style.transitionDelay = '' this.container.style.height = `${newRect.height / scale}px` this.container.style.width = `${newRect.width / scale}px` - - maxContainerDimensions.width = Math.max( - containerRect.width / scale, - newRect.width / scale, - ) - maxContainerDimensions.height = Math.max( - containerRect.height / scale, - newRect.height / scale, - ) }) promises.push(