@@ -81,40 +81,33 @@ const TreeNode = ({
8181 />
8282 ) ;
8383
84- if ( treeIndex !== listIndex ) {
85- // This row has been shifted
84+ if ( treeIndex !== listIndex && i === swapDepth ) {
85+ // This row has been shifted, and is at the depth of
86+ // the line pointing to the new destination
8687 let highlightLineClass = '' ;
87- if ( i === swapDepth ) {
88- // This block is at the depth of the line pointing to the new destination
8988
90- if ( listIndex === swapFrom + swapLength - 1 ) {
91- // This block is on the bottom (target) line
92- highlightLineClass = styles . highlightBottomLeftCorner ;
93- } else if ( treeIndex === swapFrom ) {
94- // This block is on the top (source) line
95- highlightLineClass = styles . highlightTopLeftCorner ;
96- } else {
97- // This block is between the bottom and top
98- highlightLineClass = styles . highlightLineVertical ;
99- }
100- } else if ( i === swapDepth + 1 && listIndex === swapFrom + swapLength - 1 ) {
89+ if ( listIndex === swapFrom + swapLength - 1 ) {
90+ // This block is on the bottom (target) line
10191 // This block points at the target block (where the row will go when released)
102- highlightLineClass = styles . highlightArrow ;
92+ highlightLineClass = styles . highlightBottomLeftCorner ;
93+ } else if ( treeIndex === swapFrom ) {
94+ // This block is on the top (source) line
95+ highlightLineClass = styles . highlightTopLeftCorner ;
96+ } else {
97+ // This block is between the bottom and top
98+ highlightLineClass = styles . highlightLineVertical ;
10399 }
104100
105- // Add the highlight line block if it met one of the conditions above
106- if ( highlightLineClass ) {
107- scaffold . push (
108- < div
109- key = { `highlight_${ i } ` }
110- style = { {
111- width : scaffoldBlockPxWidth ,
112- left : scaffoldBlockPxWidth * i ,
113- } }
114- className = { `${ styles . absoluteLineBlock } ${ highlightLineClass } ` }
115- />
116- ) ;
117- }
101+ scaffold . push (
102+ < div
103+ key = { `highlight_${ i } ` }
104+ style = { {
105+ width : scaffoldBlockPxWidth ,
106+ left : scaffoldBlockPxWidth * i ,
107+ } }
108+ className = { `${ styles . absoluteLineBlock } ${ highlightLineClass } ` }
109+ />
110+ ) ;
118111 }
119112 } ) ;
120113
0 commit comments