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

Refactor transition-group to use per-element state machines #474

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

nonphoto
Copy link

@nonphoto nonphoto commented Jul 18, 2023

WIP

This PR is an effort to resolve Issue #466 by taking the best of both worlds from transition-group and presence

As mentioned in #466 presence primarily works by deriving element appearance from transition state. However, it is missing:

  1. Modes: parallel and in-out
  2. Callbacks for animation completion (instead of duration-based timeout)
  3. List transitions

In opposition, transition-group works by attaching callbacks to elements that have already rendered. It is lacking:

  1. Access to transition state from within the transitioning item's context
  2. The ability to run different animations per transitioning element.

This PR resolves these differences by introducing the TransitionItemContext type, an instance of which holds the transition state for each element in a list. createListTransition now returns an array of tuples: [T, TransitionItemContext]. The user can use TransitionItemContext to register transition events or track the transition state independently for each element.

Currently only createListTransition has been modified. If this PR goes over well I will extend the functionality to createTransition as well.


This also has the added benefit of removing from jank from the playground's transitions.

Old:

Screen.Recording.2023-07-18.at.4.26.14.PM.mov

New:

Screen.Recording.2023-07-18.at.4.01.44.PM.mov

@changeset-bot
Copy link

changeset-bot bot commented Jul 18, 2023

⚠️ No Changeset found

Latest commit: 84e7192

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@nonphoto
Copy link
Author

Currently experiencing issues with animation sequencing: callbacks work correctly but animations are not playing in the correct sequence or measuring at the right moment for all options.

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

1 participant