@@ -3,12 +3,12 @@ import { Rect } from '@antv/g';
33import { isFunction } from '@antv/util' ;
44import { COMBO_KEY , CanvasEvent , ComboEvent , CommonEvent } from '../constants' ;
55import type { RuntimeContext } from '../runtime/types' ;
6- import type { EdgeDirection , ID , IElementDragEvent , IPointerEvent , Point , Prefix , State } from '../types' ;
6+ import type { EdgeDirection , ID , IElementDragEvent , IPointerEvent , Point , Prefix , State , Vector2 } from '../types' ;
77import { getBBoxSize , getCombinedBBox } from '../utils/bbox' ;
88import { isToBeDestroyed } from '../utils/element' ;
99import { idOf } from '../utils/id' ;
1010import { subStyleProps } from '../utils/prefix' ;
11- import { divide , subtract } from '../utils/vector' ;
11+ import { divide , rotate , subtract } from '../utils/vector' ;
1212import type { BaseBehaviorOptions } from './base-behavior' ;
1313import { BaseBehavior } from './base-behavior' ;
1414
@@ -354,6 +354,11 @@ export class DragElement extends BaseBehavior<DragElementOptions> {
354354 return ! ! enable ;
355355 }
356356
357+ protected clampByRotation ( [ dx , dy ] : Point ) : Vector2 {
358+ const rotation = this . context . graph . getRotation ( ) ;
359+ return rotate ( [ dx , dy ] , rotation ) ;
360+ }
361+
357362 /**
358363 * <zh/> 移动元素
359364 *
@@ -367,7 +372,7 @@ export class DragElement extends BaseBehavior<DragElementOptions> {
367372 const { dropEffect } = this . options ;
368373
369374 if ( dropEffect === 'move' ) ids . forEach ( ( id ) => model . refreshComboData ( id ) ) ;
370- graph . translateElementBy ( Object . fromEntries ( ids . map ( ( id ) => [ id , offset ] ) ) , false ) ;
375+ graph . translateElementBy ( Object . fromEntries ( ids . map ( ( id ) => [ id , this . clampByRotation ( offset ) ] ) ) , false ) ;
371376 }
372377
373378 private moveShadow ( offset : Point ) {
0 commit comments