File tree Expand file tree Collapse file tree
packages/blockly/core/dragging Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -664,25 +664,31 @@ export class BlockDragStrategy implements IDragStrategy {
664664 const bounds = root ?. getBoundingRectangle ( ) ;
665665 if ( ! bounds ) return ;
666666
667+ const blockRects = draggingBlock . workspace
668+ . getTopBlocks ( )
669+ . map ( ( block ) => block . getBoundingRectangle ( ) ) ;
670+ const blocksLeft = Math . min ( ...blockRects . map ( ( rect ) => rect . left ) ) ;
671+
667672 let destination : Coordinate ;
673+ let blockBound : number ;
668674 switch ( direction ) {
669675 case Direction . LEFT :
670676 case Direction . UP :
677+ blockBound = Math . min ( ...blockRects . map ( ( rect ) => rect . top ) ) ;
671678 destination = new Coordinate (
672- bounds . getOrigin ( ) . x ,
673- bounds . getOrigin ( ) . y -
679+ blocksLeft ,
680+ blockBound -
674681 this . BLOCK_CONNECTION_OFFSET * 2 -
675682 draggingBlock . getHeightWidth ( ) . height ,
676683 ) ;
677684 break ;
678685 case Direction . RIGHT :
679686 case Direction . DOWN :
680687 default :
688+ blockBound = Math . max ( ...blockRects . map ( ( rect ) => rect . bottom ) ) ;
681689 destination = new Coordinate (
682- bounds . getOrigin ( ) . x ,
683- bounds . getOrigin ( ) . y +
684- bounds . getHeight ( ) +
685- this . BLOCK_CONNECTION_OFFSET * 2 ,
690+ blocksLeft ,
691+ blockBound + this . BLOCK_CONNECTION_OFFSET * 2 ,
686692 ) ;
687693 break ;
688694 }
You can’t perform that action at this time.
0 commit comments