Animate from a list
See original GitHub issueI’m not sure this is an issue related to Moti but I can’t find a way to animate an array of cards. All our code is doing is updating a state called currentDiscoverIndex
to update a list of artworks. I have a correct animation on mount but when I update the state the animation is very junky. I’m not sure if this is due to keys not being added correctly. I just can’t figure out what I’m doing wrong.
Here is my code:
Container
const Wrapper = styled(AnimatePresence)<{ containerHeight: number }>(
({ containerHeight }) => ({
width: '100%',
height: containerHeight,
}),
);
const newArtworks = useMemo(
() => artworks.slice(currentDiscoverIndex, currentDiscoverIndex + count),
[artworks, currentDiscoverIndex],
);
return (
<Wrapper containerHeight={containerHeight}>
{newArtworks.map((card) => (
<Card
key={card.id}
artwork={card}
containerHeight={containerHeight}
/>
))}
</Wrapper>
)
Card component
const Wrapper = styled(MotiView)({
width: '100%',
height: '100%',
});
<Wrapper
key={artwork.id}
from={{
opacity: 0,
translateX: -40,
}}
animate={{
opacity: 1,
translateX: 0,
}}
exit={{
opacity: 0,
translateX: -40,
}}>
{ ... }
</Wrapper>
Any chance someone has an idea where I could do something wrong?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How To Animate Items In List Using AnimatedList In Flutter
An AnimatedList is a List that animates the item when inserted or removed. Let's try to build something like this. Animated Widget Code...
Read more >ListAnimate - Wolfram Language Documentation
ListAnimate[{expr1, expr2, ...}] generates an animation whose frames are the successive expri. ListAnimate[list, fps] displays fps frames per second.
Read more >Animating List Items - CSS Animation
As a first animation we'll add a simple fade effect. The list items appear a little more gradually than before. Visually this still...
Read more >AnimatedList (Flutter Widget of the Week) - YouTube
Use AnimatedList to make your lists more dynamic. You can use it to animate your lists when inserting or removing items.
Read more >SwiftUI: How to animate List when … | Apple Developer Forums
I want to display a simple message while waiting for a list to be populated. Something like Loading... and when the list starts...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I see. For starters, AnimatePresence doesn’t accept styles, so that doesn’t apply
It is indeed working correctly now 👍 Thanks a lot for your help.