Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Web LA] Add CurvedTransition #6239

Merged
merged 28 commits into from
Jul 22, 2024
Merged

[Web LA] Add CurvedTransition #6239

merged 28 commits into from
Jul 22, 2024

Conversation

m-bert
Copy link
Contributor

@m-bert m-bert commented Jul 9, 2024

Summary

This PR adds CurvedTransition to set of transitions available on web.

This transition is different from others, therefore logic behind its creation is also different.

Logic

Logic behind this transition is a bit complicated since CSS does not allow to specify different easings to different properties.

In order to achieve desired effect, we have to use second component. One of them will run animation along Y axis and the other one along X axis. This will result in child component being animated with combined easings.

Current logic works as follows:

  1. Clone element with layout transition
  2. Reset all of dummy styles, so that it is placed exactly at elements position
  3. Hide all of elements children and set element background color to transparent
  4. Add dummy as element child
  5. Start animations for both element and dummy
  6. After animation ends, remove dummy from children of element
  7. Show all children of element and bring back old background color

Examples

Nagranie.z.ekranu.2024-07-9.o.14.55.12.mov
Nagranie.z.ekranu.2024-07-9.o.14.54.21.mov

Limitations

Currently CurvedTransition is not applied to width/height. Also I'm not yet sure how it interacts with background images.

Test plan

Verified on DefaultLayoutTransitions example (with easingX changed to sin and easingY to exp).

@m-bert m-bert marked this pull request as ready for review July 9, 2024 12:59
@m-bert m-bert requested review from piaskowyk July 9, 2024 13:03
Copy link
Member

@piaskowyk piaskowyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can try a bit different approach like here - https://tobiasahlin.com/blog/curved-path-animations-in-css/

@m-bert
Copy link
Contributor Author

m-bert commented Jul 17, 2024

Main problem with using ::after is that we cannot add children to it, therefore we would either have to hide them, or leave them animate along one axis, which I believe is unacceptable.

Current approach does almost the same thing, but clones element rather than using ::after (which also adds this pseudoelement as elements' child). Moreover, it takes advantage of already existing custom animations mechanism (i.e. adding them and clearing).

I think we can stick to current approach, but I'm open to discussion.

@m-bert m-bert mentioned this pull request Jul 22, 2024
@m-bert m-bert added this pull request to the merge queue Jul 22, 2024
Merged via the queue into main with commit c5a50f5 Jul 22, 2024
6 checks passed
@m-bert m-bert deleted the @mbert/add-curved-transition branch July 22, 2024 12:19
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.

None yet

2 participants