Skip to content

Crossfade opacity is incorrect #6668

Open
@Rich-Harris

Description

@Rich-Harris

Describe the bug

When using crossfade to transition between two elements, the in element goes from 0 to o (where o is the natural opacity) while the out element goes from o to 0.

The result is that at the midpoint, the combined opacity is less than either element's natural opacity. In the common case where both elements have a natural opacity of 1, the combined opacity at the midpoint is 1 - 0.5^2 = 0.75.

This can be solved with a quadratic blending formula with special handling for the common case (which is complicated by the need to know which element is on top of the other).

Reproduction

https://svelte.dev/repl/6dc637d0321f41f983da99907b2f451d?version=3.42.1

This also showcases a separate bug, which is a dupe of #4389. (There are several open crossfade issues; the whole thing probably needs a bit of a cleanup.)

Logs

No response

System Info

Svelte 3.42.1

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugruntimeChanges relating to runtime APIs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions