Glitchy animation when dropping item
See original GitHub issueHi, I am experiencing a weird animation when sorting a list of elements.
I cannot provide the exact codebase, but I have built it on top of the story presets > sortable > multiple containers > many items
.
Here below you can see a video of the problem.
Notice how the<DragOverlay />
falls correctly into place, while the remaining elements shifts up in a weird way.
I have spent quite some time trying to track down the problem, but with no result so far. Anybody has idea of what could be the cause?
Thanks.
Issue Analytics
- State:
- Created a year ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Visual bug on drop #2086 - atlassian/react-beautiful-dnd
Actual behavior. After dropping a draggable element, there is a visual bug as shown in the following GIF.
Read more >How to create high-performance CSS animations - web.dev
This guide teaches you how to create high-performance CSS animations. See Why are some animations slow? to learn the theory behind these ...
Read more >Animation Techniques for Adding and Removing Items From a ...
Animating elements with CSS can either be quite easy or quite difficult depending on what you are trying to do.
Read more >An Interactive Guide to CSS Transitions - Josh W Comeau
When we animate an element using transform and opacity , the browser will sometimes try to optimize this animation. Instead of rasterizing the ......
Read more >How to Create a Glitch Effect in After Effects - School of Motion
So in today's tutorial, we are going to make this glitch effect that you can set up once and then drop over any...
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
@MTxx87 the problem in your case is that you are not using a stable
key
property. You are passing theindex
as thekey
property to your list items, which causes them to unmount and re-mount when the order of the list changes.Use the unique
id
property of your items instead as thekey
:https://codesandbox.io/s/rough-cookies-53w0rj?file=/src/Items.tsx
You can read more about using stable keys here:
https://reactjs.org/docs/lists-and-keys.html#keys
@clauderic It worked when adding the proper
key
. Thank you!