MCPcopy Create free account
hub / github.com/react-dnd/react-dnd / moveCard

Method moveCard

examples/04 Sortable/Stress Test/Container.js:35–52  ·  view source on GitHub ↗
(id, afterId)

Source from the content-addressed store, hash-verified

33 }
34
35 moveCard(id, afterId) {
36 const { cardsById, cardsByIndex } = this.state;
37
38 const card = cardsById[id];
39 const afterCard = cardsById[afterId];
40
41 const cardIndex = cardsByIndex.indexOf(card);
42 const afterIndex = cardsByIndex.indexOf(afterCard);
43
44 this.scheduleUpdate({
45 cardsByIndex: {
46 $splice: [
47 [cardIndex, 1],
48 [afterIndex, 0, card],
49 ],
50 },
51 });
52 }
53
54 componentWillUnmount() {
55 cancelAnimationFrame(this.requestedFrame);

Callers 1

hoverFunction · 0.45

Calls 1

scheduleUpdateMethod · 0.95

Tested by

no test coverage detected