(id, afterId)
| 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); |