@@ -663,7 +663,7 @@ function containerMouseDown(e: MouseEvent) {
663663 infoBox .value .startY = e .pageY
664664}
665665
666- function getNowPosition(addSizeX : number , addSizeY : number ) {
666+ function getNowPosition(addSizeX : number , addSizeY : number , moveXSize : number , moveYSize : number ) {
667667 const point = infoBox .value .point
668668 const hasT = / t/ .test (point )
669669 const hasB = / b/ .test (point )
@@ -674,66 +674,49 @@ function getNowPosition(addSizeX: number, addSizeY: number) {
674674 let nowSizeY = infoBox .value .oldSizeY
675675 let nowX = infoBox .value .oldX
676676 let nowY = infoBox .value .oldY
677- // Move the lowest position from point L
678- const nowBottomX = nowX + nowSizeX - 1
679- if (hasR ) {
680- nowSizeX = Math .max (nowSizeX + addSizeX , 1 )
681- }
682- if (hasB ) {
683- nowSizeY = Math .max (nowSizeY + addSizeY , 1 )
684- }
685-
686- if (hasL ) {
687- nowSizeX = Math .max (nowSizeX - addSizeX , 1 )
688- // Move the lowest position from point L
689- nowX = Math .min (Math .max (nowX + addSizeX , 1 ), nowBottomX )
690- }
691-
692- if (hasT ) {
693- nowSizeY = Math .max (nowSizeY - addSizeY , 1 )
694- nowY = Math .max (nowY + addSizeY , 1 )
695- }
696- return {nowSizeX , nowSizeY , nowX , nowY }
697- }
698677
699-
700- function getNowClonePosition(moveXSize : number , moveYSize : number ) {
701- const point = infoBox .value .point
702- const hasT = / t/ .test (point )
703- const hasB = / b/ .test (point )
704- const hasL = / l/ .test (point )
705- const hasR = / r/ .test (point )
706- // Determine the resizing direction based on the coordinate points
707678 let nowOriginWidth = infoBox .value .originWidth
708679 let nowOriginHeight = infoBox .value .originHeight
709680 let nowOriginX = infoBox .value .originX
710681 let nowOriginY = infoBox .value .originY
682+
711683 // Move the lowest position from point T
712684 const nowBottomOriginY = nowOriginY + nowOriginHeight - baseHeight .value
713685 // Move the lowest position from point L
714- const nowBottomOriginX = nowOriginX + nowOriginWidth - baseWidth .value
686+ const nowLeftOrigin = nowOriginX + nowOriginWidth - baseWidth .value
687+ const nowBottomX = nowX + nowSizeX - 1
715688 if (hasR ) {
689+ nowSizeX = Math .max (nowSizeX + addSizeX , 1 )
716690 nowOriginWidth = Math .max (nowOriginWidth + moveXSize , baseWidth .value )
691+
717692 }
718693 if (hasB ) {
694+ nowSizeY = Math .max (nowSizeY + addSizeY , 1 )
719695 nowOriginHeight = Math .max (nowOriginHeight + moveYSize , baseHeight .value )
696+
720697 }
721698
722699 if (hasL ) {
723- nowOriginWidth = Math .max (nowOriginWidth - moveXSize , baseWidth .value )
700+ // Do not exceed the left boundary
701+ nowSizeX = Math .min (Math .max (nowSizeX - addSizeX , 1 ), nowBottomX )
724702 // Move the lowest position from point L
725- nowOriginX = Math .min (Math .max (nowOriginX + moveXSize , 1 ), nowBottomOriginX )
703+ nowX = Math .min (Math .max (nowX + addSizeX , 1 ), nowBottomX )
704+
705+ nowOriginWidth = Math .min (Math .max (nowOriginWidth - moveXSize , baseWidth .value ), nowLeftOrigin )
706+ // Move the lowest position from point L
707+ nowOriginX = Math .min (Math .max (nowOriginX + moveXSize , 1 ), nowLeftOrigin )
726708 }
727709
728710 if (hasT ) {
711+ nowSizeY = Math .max (nowSizeY - addSizeY , 1 )
712+ nowY = Math .max (nowY + addSizeY , 1 )
729713 nowOriginHeight = Math .max (nowOriginHeight - moveYSize , baseHeight .value )
730714 // Move the lowest position from point L
731715 nowOriginY = Math .min (Math .max (nowOriginY + moveYSize , 1 ), nowBottomOriginY )
732716 }
733- return {nowOriginWidth , nowOriginHeight , nowOriginX , nowOriginY }
717+ return {nowSizeX , nowSizeY , nowX , nowY , nowOriginWidth , nowOriginHeight , nowOriginX , nowOriginY }
734718}
735719
736-
737720function startMove(e : MouseEvent , item : CanvasItem , index : number ) {
738721 if (! draggable .value ) return
739722 dashboardStore .setCurComponent (item )
@@ -808,13 +791,21 @@ function startMove(e: MouseEvent, item: CanvasItem, index: number) {
808791 ? parseInt (String (moveYSize / cellHeight .value + 1 ))
809792 : parseInt (String (moveYSize / cellHeight .value ))
810793 // 根据坐标点 判断resize方向
811- const {nowSizeX, nowSizeY, nowX, nowY} = getNowPosition (addSizeX , addSizeY )
794+ const {
795+ nowSizeX,
796+ nowSizeY,
797+ nowX,
798+ nowY,
799+ nowOriginWidth,
800+ nowOriginHeight,
801+ nowOriginX,
802+ nowOriginY
803+ } = getNowPosition (addSizeX , addSizeY , moveXSize , moveYSize )
812804
813805 debounce (() => {
814806 resizePlayer (resizeItem , {sizeX: nowSizeX , sizeY: nowSizeY , x: nowX , y: nowY })
815807 }, 10 )
816808
817- const {nowOriginWidth, nowOriginHeight, nowOriginX, nowOriginY} = getNowClonePosition (moveXSize , moveYSize )
818809 infoBox .value .cloneItem .style .width = ` ${nowOriginWidth }px `
819810 infoBox .value .cloneItem .style .height = ` ${nowOriginHeight }px `
820811 infoBox .value .cloneItem .style .left = ` ${nowOriginX }px `
0 commit comments