- if (
- itemOffset &&
- overIndex !== dragItemIndex
- ) {
- if ( this.orientation === 'horizontal' ) {
- // Calculate where the mouse is relative to the item width
- itemSize = itemBoundingRect.width;
- itemMidpoint = itemBoundingRect.left + itemSize / 2;
- dragPosition = clientX;
- // Which side of the item we hover over will dictate
- // where to drop the selected item, on the left or
- // on the right
- cssOutput = {
- left: dragPosition < itemMidpoint ? itemPosition.left : itemPosition.left + itemSize,
- top: itemPosition.top
- };
- } else {
- // Calculate where the mouse is relative to the item height
- itemSize = itemBoundingRect.height;
- itemMidpoint = itemBoundingRect.top + itemSize / 2;
- dragPosition = clientY;
- // Which side of the item we hover over will dictate
- // where to drop the selected item, on the top or
- // on the bottom
- cssOutput = {
- top: dragPosition < itemMidpoint ? itemPosition.top : itemPosition.top + itemSize,
- left: itemPosition.left
- };
- }
- // Store whether we are before or after an item to rearrange
- // For horizontal layout, we need to account for RTL, as this is flipped
- if ( this.orientation === 'horizontal' && this.dir === 'rtl' ) {
- after = dragPosition < itemMidpoint;
- } else {
- after = dragPosition > itemMidpoint;
- }
- targetIndex = overIndex + ( after ? 1 : 0 );
- // Check the targetIndex isn't immediately to the left or right of the current item (a no-op)
- if ( targetIndex === dragItemIndex || targetIndex === dragItemIndex + 1 ) {
- targetIndex = null;
- }
- }
- if ( targetIndex !== null ) {