add crossfade and flip functions #2247
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ref #2241.
Not sure if these are ready to be promoted to built-in functions yet. I'm encountering occasional hard-to-reproduce positioning bugs, and
crossfade
doesn't handle changes in size (but maybe that's ok given its intended use? I think we can accommodate size changes, it just involvesstyle.transformOrigin
and some arithmetic).Also, if you look really closely the
crossfade
opacity isn't quite right — since one side goes from 0 to 1 and the other goes from 1 to 0, in the middle they're both 0.5 which results in a total opacity of 0.75, when you really want the total opacity to stay at 1 throughout. Unfortunately the only way to achieve that is to use this blending formula which requires that you know which element is on top, which you could maybe do withgetElementsFromPoint
but otherwise you have to figure out stacking order using something like https://gitlab.com/Rich-Harris/stacking-order.On the other hand, these effects are difficult to achieve by hand, so maybe we should include these functions and treat any updates as bugfixes so as not to anger the semver gods? At the very least I think we have the right API now: