@@ -2,7 +2,6 @@ import { DragDrop, DragRef } from '@angular/cdk/drag-drop';
22import { effect , ElementRef , Injectable , NgZone , OnDestroy , signal , WritableSignal } from '@angular/core' ;
33import { animationFrameScheduler , fromEvent , interval , Subject } from 'rxjs' ;
44import { takeUntil } from 'rxjs/operators' ;
5- import { GanttViewType } from '../../class' ;
65import { GanttItemInternal } from '../../class/item' ;
76import { GanttLinkType } from '../../class/link' ;
87import { GanttDomService } from '../../gantt-dom.service' ;
@@ -376,35 +375,13 @@ export class GanttBarDrag implements OnDestroy {
376375
377376 private barDragMove ( ) {
378377 const currentX = this . item ( ) . refs . x + this . barDragMoveDistance + this . dragScrollDistance ;
379- const currentDate = this . ganttUpper . view . getDateByXPoint ( currentX ) ;
380- const currentStartX = this . ganttUpper . view . getXPointByDate ( currentDate ) ;
381- const currentEndDate = this . ganttUpper . view . getDateByXPoint ( currentX + this . item ( ) . refs . width ) ;
382-
383- const diffs = this . ganttUpper . view . differenceByPrecisionUnit ( currentEndDate , currentDate ) ;
384-
385- let start = currentDate ;
386- let end = currentDate . add ( diffs , this . ganttUpper . view ?. options ?. datePrecisionUnit ) ;
387-
388- // 日视图特殊逻辑处理
389- if ( this . ganttUpper . view . viewType === GanttViewType . day ) {
390- const dayWidth = this . ganttUpper . view . getDayOccupancyWidth ( currentDate ) ;
391- if ( currentX > currentStartX + dayWidth / 2 ) {
392- start = start . addDays ( 1 ) ;
393- end = end . addDays ( 1 ) ;
394- }
395- }
396-
378+ const start = this . ganttUpper . view . getDateByXPoint ( currentX ) ;
379+ const end = this . ganttUpper . view . getEndDateByWidth ( start , this . item ( ) . refs . width ) ;
397380 if ( this . dragScrolling ) {
398381 const left = currentX - this . barDragMoveDistance ;
399382 this . barElement . style . left = left + 'px' ;
400383 }
401-
402- this . openDragBackdrop (
403- this . barElement ,
404- this . ganttUpper . view . getDateByXPoint ( currentX ) ,
405- this . ganttUpper . view . getDateByXPoint ( currentX + this . item ( ) . refs . width )
406- ) ;
407-
384+ this . openDragBackdrop ( this . barElement , start , end ) ;
408385 if ( ! this . isStartOrEndInsideView ( start , end ) ) {
409386 return ;
410387 }
0 commit comments