Skip to content

fix(layers): anchor timeline scale animation on layer visual center#843

Merged
hm21 merged 2 commits into
stablefrom
fix/layer-animation-scale
Jul 1, 2026
Merged

fix(layers): anchor timeline scale animation on layer visual center#843
hm21 merged 2 commits into
stablefrom
fix/layer-animation-scale

Conversation

@hm21

@hm21 hm21 commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Problem

A layer whose video-timeline animation combines a slide-in (e.g. from the top) with a scale-in did not enter straight — it drifted in diagonally, appearing to come "from the top-right".

Root cause

The scale was applied with Transform.scale's default alignment: Alignment.center, which scales around the layout-box center. But the layer content is painted shifted by _fractionalOffset (default (-0.5, -0.5)), so the layer's visual center actually sits at the box's top-left corner. Scaling around the box center pulls the shrunk layer toward the center — down and to the right — decaying to zero as scale reaches 1. Combined with the slide-from-top, this reads as entering from the top-right instead of straight down.

This also meant the in-editor preview disagreed with the natively rendered export, which scales around the true center.

Fix

Anchor the scale on the layer's visual center. With fractional offset fo, the visual center is at box fraction (0.5+fo.dx, 0.5+fo.dy), i.e. Transform.scale alignment Alignment(2·fo.dx, 2·fo.dy)Alignment.topLeft for the default (-0.5,-0.5). The layer's fractional offset is plumbed into LayerTimelineVisibility.

With the anchor fixed, scaling introduces no horizontal (or vertical) drift, so a slide-from-top brings the layer straight down.

Tests

Two regression tests added covering the scale anchor for the default (-0.5,-0.5) offset (→ topLeft) and a centered (0,0) offset (→ center). All 14 tests in the suite pass and dart analyze is clean.

hm21 added 2 commits July 1, 2026 11:59
A layer combining a slide-in (e.g. from the top) with a scale-in drifted
in diagonally instead of straight down. Transform.scale used the default
center alignment (the layout-box center), but the layer content is painted
shifted by _fractionalOffset (default -0.5,-0.5), placing its visual center
at the box top-left. Scaling around the box center pulled the shrinking
layer toward the center (down-right), which combined with the slide read as
entering from the top-right.

Anchor the scale on the layer's visual center via Alignment(2*fo.dx,
2*fo.dy), plumbing the layer's fractional offset into
LayerTimelineVisibility. Adds regression tests covering the anchor for the
default and centered offsets.
@hm21 hm21 merged commit d404791 into stable Jul 1, 2026
1 check passed
@hm21 hm21 deleted the fix/layer-animation-scale branch July 1, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant