Skip to content

Animating add/delete items #108

Answered by clauderic
ranbena asked this question in Q&A
Feb 28, 2021 · 3 comments · 16 replies
Discussion options

You must be logged in to vote

For anyone stumbling on this discussion, animating insertion / deletion of items is now possible by combining the layoutMeasuring prop of <DndContext> and the animateLayoutChanges argument of useSortable:

import {MeasuringStrategy} from '@dnd-kit/core';

const measuringConfig = {
  droppable: {
    strategy: MeasuringStrategy.Always,
  }
};

function App() {
  return (
    <DndContext measuring={measuringConfig}>
      {/* ... */}
    </DndContext>
}
import {useSortable, defaultAnimateLayoutChanges} from '@dnd-kit/sortable';

function animateLayoutChanges(args) {
  const {isSorting, wasSorting} = args;

  if (isSorting || wasSorting) {
    return defaultAnimateLayoutChanges(args);
  }

  r…

Replies: 3 comments 16 replies

This comment has been hidden.

@ranbena
Comment options

@clauderic
Comment options

@ranbena
Comment options

@clauderic
Comment options

Comment options

You must be logged in to vote
5 replies
@heroboy
Comment options

@heroboy
Comment options

@AbdallahMostafaIbrahim
Comment options

@anton-iskryk
Comment options

@petterastedt
Comment options

Answer selected by clauderic
Comment options

You must be logged in to vote
7 replies
@twiddlecoding
Comment options

@ranbena
Comment options

@twiddlecoding
Comment options

@Rudra072
Comment options

@kamil-sienkiewicz-asi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
10 participants