Skip to content

Commit

Permalink
fix: change where maxDimensions are calculated again
Browse files Browse the repository at this point in the history
  • Loading branch information
cmgriffing committed Oct 25, 2024
1 parent fa90690 commit d583322
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/shiki-magic-move/src/renderer.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit d583322

Please sign in to comment.