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

Modify AnimatedSwitcher to better allow different in vs. out transitions #19395

Closed
dalewking opened this issue Jul 16, 2018 · 7 comments
Closed
Assignees
Labels
a: animation Animation APIs c: new feature Nothing broken; request for a new capability framework flutter/packages/flutter repository. See also f: labels.

Comments

@dalewking
Copy link

See this discussion I had with myself on flutter_dev: https://groups.google.com/forum/#!topic/flutter-dev/mTKt7qJaqBM

AnimatedSwitcher is designed to use a single animation for incoming items and the reversed animation for the outgoing items. But that is not always what is desired. For example, I might want to slide new items in from the left and slide the previous item out to the right.

It is not clear how to actually achieve that with AnimatedSwitcher. As you can see in that thread I spent a day of hacking and figured out how to make it work, but there should be a better, clearly defined way to accomplish this.

My thought is another optional AnimatedSwitcherTransitionBuilder parameter like exitTransitionBuilder that can be passed to AnimatedSwitcher that is only used on the exiting items. When that parameter is present the Animation should run in the forward direction (i.e. you would not reverse the animation controller for that item).

@zoechi zoechi added the a: animation Animation APIs label Jul 16, 2018
@zoechi zoechi added c: new feature Nothing broken; request for a new capability framework flutter/packages/flutter repository. See also f: labels. labels Dec 6, 2018
@zoechi zoechi added this to the Goals milestone Dec 6, 2018
@chunhtai chunhtai self-assigned this Aug 12, 2019
@chunhtai
Copy link
Contributor

Having a different animation between child in and out might cause some unexpected behavior if we change the children really fast. The child, while is still transitioning in, gets kick to transition out. In the current behavior, the child will keep the current animation value and do the reverse. This make sense if the transition are the same, but you might see a suddenly jump due to different animation

Same animation Scale
same-animation

Different animation Scale vs Fade
different

It will jump even more if you have very different animations. I will need more clarification on what are the expected behaviors in this two cases to continue on this issue

@dalewking
Copy link
Author

That is a concern but not one that should prevent allowing for the feature. It can be a note that this is a potential issue.

In my case I was actually looking to only animate the in, and not have any out animation. I have an item that is Swipeable (with a custom implementation that allows me to swipe in any direction) and then all I do is animate the new item in.

@chunhtai
Copy link
Contributor

chunhtai commented Aug 13, 2019

@dalewking
If the use case to only do partial transition, I think allowing a different out transition builder that are kind of broken to be able to achieve your use case is not ideal. Besides, there is already a way to achieve this.

Here is a more polished version of it

We will not change the api as this way of changing the animation is not recommended; however, we will document this behavior and add a test to guard against any change to the api.

Edit: There is a bug that the initial child is placed in a forward pause direction which it should be reverse pause direction. I will fix this bug

Edit: ignore my previous response, the animation is not really useful as the state is inaccurate representation of transition phase, I will try to correct them. I think it is worth doing to simplify the logic as well. Please stay tune

@dalewking
Copy link
Author

As I posted in the linked thread there is also some weirdness that the transition builder may or may not be called on the exiting item. If it is a lambda, it fails the equals check and will be called again, if it is a method reference it compares as equal and is not called again.

@chunhtai
Copy link
Contributor

chunhtai commented Aug 20, 2019

We proceeded with the plan to not changing animatedswitcher. The reason being animatedswitcher is not really built for supporting different animations for transition in & out. It might create the risk of having broken animation, and that is against our core values. If you want to have special animation effect different from animatedswitcher, we suggest to build a custom animation widget to achieve the goal.

let me know if you have trouble doing so, I am always happy to help.

@dalewking
Copy link
Author

dalewking commented May 2, 2021 via email

@github-actions
Copy link

github-actions bot commented Aug 2, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: animation Animation APIs c: new feature Nothing broken; request for a new capability framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

No branches or pull requests

3 participants