Skip to content

Commit a5a21d9

Browse files
authored
Merge pull request #3175 from buhrmi/crossfade-scale
make crossfade scale the element to target rect
2 parents 6adf7b3 + 757ebc7 commit a5a21d9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/runtime/transition/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ export function crossfade({ fallback, ...defaults }: CrossfadeParams & {
188188
const to = node.getBoundingClientRect();
189189
const dx = from.left - to.left;
190190
const dy = from.top - to.top;
191+
const dw = from.width / to.width;
192+
const dh = from.height / to.height;
191193
const d = Math.sqrt(dx * dx + dy * dy);
192194

193195
const style = getComputedStyle(node);
@@ -200,7 +202,8 @@ export function crossfade({ fallback, ...defaults }: CrossfadeParams & {
200202
easing,
201203
css: (t, u) => `
202204
opacity: ${t * opacity};
203-
transform: ${transform} translate(${u * dx}px,${u * dy}px);
205+
transform-origin: top left;
206+
transform: ${transform} translate(${u * dx}px,${u * dy}px) scale(${t + (1-t) * dw}, ${t + (1-t) * dh});
204207
`
205208
};
206209
}

0 commit comments

Comments
 (0)