Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Animate removed item out of the list #10

Closed
arackaf opened this issue Apr 21, 2020 · 9 comments
Closed

Animate removed item out of the list #10

arackaf opened this issue Apr 21, 2020 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@arackaf
Copy link

arackaf commented Apr 21, 2020

Hi - wonderful library. From what I can tell it doesn't seem possible to set an animation for an item that's being removed from a list - is that true? For example, in your planets demo, if I wanted to remove Pluto, have it fly off to the left as the other planets move in to fill the space.

Would that be a feature you'd be interested in? I'd love to give it a shot if you think it's a good idea.

@jlkiri jlkiri added the enhancement New feature or request label Apr 22, 2020
@jlkiri
Copy link
Owner

jlkiri commented Apr 22, 2020

Sounds good! I think this is something that many need and is naturally expected to happen. It probably boils down to how an element can be animated when it is no longer rendered (= removed from DOM)

In React I would normally animate it first and then have it removed from DOM when the animation is finished with ontransitionend, but maybe there are better approaches.

@JasCodes
Copy link

Lol I was just about request the same 😂

@jlkiri
Copy link
Owner

jlkiri commented Apr 23, 2020

Here's a simple example of how to achieve this with current API
(click on items to remove them)
(see fadeOut function)

https://codesandbox.io/s/list-shuffling-flip-2-iuqdr?file=/src/App.js

If an item is removed, other items already smoothly move in to fill the space. However, there are a couple of shortcomings:

  • This solution forces the user to directly access DOM
  • Does not animate newly added items properly for some reason

So it would be ideal to fix these two.

@arackaf
Copy link
Author

arackaf commented Apr 23, 2020

I'll be perfectly up-front: I don't think I'll be able to get to this as quickly as I'd hoped when I opened this case. If you want to close this issue, I won't be remotely offended.

Fingers crossed some other braze soul is up for the challenge :)

@jlkiri
Copy link
Owner

jlkiri commented Apr 23, 2020

@arackaf It's OK. I will try to come up with something over the weekend.

@jlkiri
Copy link
Owner

jlkiri commented Apr 28, 2020

So, initially I was going to come up with some quick solution, but now I think there's room for a bigger refactor. Manipulating transitions from JS is a pain and more complex functionality will probably lead to more hacks which I want to avoid.

However, I noticed that (apart from some reported bugs) Web Animations API is enabled in all modern browsers now. I think I am going to do a rewrite that uses the animate() function and this in turn might help to add more complex interactions.

@jlkiri jlkiri added this to the Use Web Animations API for animation milestone Apr 28, 2020
@arackaf
Copy link
Author

arackaf commented Apr 28, 2020

@jlkiri that sounds amazing man!

@jlkiri jlkiri self-assigned this May 2, 2020
@jlkiri jlkiri removed this from the Use Web Animations API for animation milestone May 2, 2020
@jlkiri
Copy link
Owner

jlkiri commented May 16, 2020

It's now possible in react-easy-flip@beta with an experimental <AnimateInOut> component.

@jlkiri jlkiri closed this as completed May 16, 2020
@arackaf
Copy link
Author

arackaf commented May 16, 2020

Oh damn - nice!!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants