@@ -49,8 +49,8 @@ function useSortable(initialItems) {
49
49
return items ;
50
50
}
51
51
52
- // This is the whole state of the library is managed
53
- // this "produce" stuff comes from immer and makes updating immutable data less painful
52
+ // This is where the state is managed
53
+ // "produce" stuff comes from immer and makes updating immutable data less painful
54
54
function reducer ( state , action ) {
55
55
switch ( action . type ) {
56
56
// When sortable components are mounted they are added to "elements" array
@@ -129,8 +129,7 @@ function Sortable(props) {
129
129
containerRef . current . addEventListener ( "touchstart" , dragStart , false ) ;
130
130
window . addEventListener ( "touchend" , dragEnd , false ) ;
131
131
window . addEventListener ( "touchmove" , drag , false ) ;
132
- // If your effect returns a function React will run it when it is time to clean up
133
- // This has similar logic to componentWillUnmount
132
+ // If your effect returns a function React will run it when it is time to clean up (componentWillUnmount)
134
133
return ( ) => {
135
134
containerRef . current . removeEventListener ( 'mousedown' , dragStart , false ) ;
136
135
window . removeEventListener ( 'mousemove' , drag , false ) ;
@@ -167,7 +166,7 @@ function Sortable(props) {
167
166
168
167
// We want to animate our nodes
169
168
state . nodes . forEach ( ( node , i ) => {
170
- if ( i !== state . draggedElement . draggedElement ) {
169
+ if ( i !== state . draggedElementIndex ) {
171
170
node . style . webkitTransition = 'transform 0.3s' ;
172
171
}
173
172
} ) ;
0 commit comments