Skip to content

Commit 385737a

Browse files
committed
Allow FLIP animations perform correctly in scaled parent
- get the scale factor by comparing against node.clientWidth - divide all the positions/dimensions by the scale to get the correct deltas - resolves #7205 - fixes regression from #6658
1 parent 2f71bc9 commit 385737a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/runtime/animate/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ export function flip(node: Element, { from, to }: { from: DOMRect; to: DOMRect }
2121
const transform = style.transform === 'none' ? '' : style.transform;
2222

2323
const [ox, oy] = style.transformOrigin.split(' ').map(parseFloat);
24-
const dx = (from.left + from.width * ox / to.width) - (to.left + ox);
25-
const dy = (from.top + from.height * oy / to.height) - (to.top + oy);
24+
const scale = {
25+
x: to.width / node.clientWidth,
26+
y: to.height / node.clientHeight
27+
};
28+
const dx = ((from.left / scale.x) + (from.width / scale.x) * ox / (to.width / scale.x)) - ((to.left / scale.x) + ox);
29+
const dy = ((from.top / scale.y) + (from.height / scale.y) * oy / (to.height / scale.y)) - ((to.top / scale.y) + oy);
2630

2731
const {
2832
delay = 0,

0 commit comments

Comments
 (0)