File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
examples/04 Sortable/Simple Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,10 @@ const style = {
12
12
13
13
const cardSource = {
14
14
beginDrag ( props ) {
15
- return { id : props . id } ;
15
+ return {
16
+ id : props . id ,
17
+ index : props . index
18
+ } ;
16
19
}
17
20
} ;
18
21
@@ -23,10 +26,9 @@ const cardTarget = {
23
26
if ( draggedId === ownId ) {
24
27
return ;
25
28
}
26
-
27
- // assuming something like findTodoIndex is implemented
28
- const ownIndex = props . findTodoIndex ( ownId ) ;
29
- const draggedIndex = props . findTodoIndex ( draggedId ) ;
29
+
30
+ const ownIndex = props . index ;
31
+ const draggedIndex = monitor . getItem ( ) . index ;
30
32
31
33
// What is my rectangle on screen?
32
34
const boundingRect = React . findDOMNode ( component ) . getBoundingClientRect ( ) ;
Original file line number Diff line number Diff line change @@ -62,9 +62,10 @@ export default class Container extends Component {
62
62
63
63
return (
64
64
< div style = { style } >
65
- { cards . map ( card => {
65
+ { cards . map ( ( card , i ) => {
66
66
return (
67
67
< Card key = { card . id }
68
+ index = { i }
68
69
id = { card . id }
69
70
text = { card . text }
70
71
moveCard = { this . moveCard } />
You can’t perform that action at this time.
0 commit comments