1
0
tangning 16 часов назад
Родитель
Сommit
8d069b693e
1 измененных файлов с 23 добавлено и 5 удалено
  1. 23 5
      src/view/case/photos/canvas-photo-editor.js

+ 23 - 5
src/view/case/photos/canvas-photo-editor.js

@@ -486,7 +486,7 @@ export class CanvasPhotoEditor {
     const mouseX = (e.clientX - rect.left - this.drawOffsetX) / this.scale
     const mouseY = (e.clientY - rect.top - this.drawOffsetY) / this.scale
     let coordinate = this.pages[PhotoIndex.pageIndex].coordinate[PhotoIndex.itemIndex]
-    console.log('coordinate', PhotoIndex, oldPhotoIndex)
+    console.log('coordinate',coordinate, PhotoIndex, oldPhotoIndex)
     this.indexingEndX = mouseX
     this.indexingEndY = mouseY
     let startInfo = this.indexingList[0]
@@ -496,7 +496,12 @@ export class CanvasPhotoEditor {
       x: this.indexingStartX,
       y: startInfo.itemIndex > PhotoIndex.itemIndex ? (coordinate.y + coordinate.height + 3) : coordinate.y -3,
     }
-    if (startInfo.pageIndex != PhotoIndex.pageIndex && startInfo.count == PhotoIndex.count && startInfo.itemIndex == PhotoIndex.itemIndex) {
+    if(startInfo.count == 2 && startInfo.count == PhotoIndex.count && startInfo.itemIndex == PhotoIndex.itemIndex){
+      endIindexing1 = {//同item页面 同数量
+        x: mouseX,
+        y: PhotoIndex.itemIndex == 0?coordinate.y:(coordinate.y+coordinate.height),
+      }
+    } else if (startInfo.pageIndex != PhotoIndex.pageIndex && startInfo.count == PhotoIndex.count && startInfo.itemIndex == PhotoIndex.itemIndex) {
       //不同页码 item 相同
       endIindexing1 = {//同数量同item
         x: startInfo.pageIndex > PhotoIndex.pageIndex ? (coordinate.x + coordinate.width + 3) : coordinate.x -3,
@@ -517,8 +522,11 @@ export class CanvasPhotoEditor {
       let newX = addPage*(this.pageWidth + this.pageMargin)
       points.splice(1, 0, { x: newX, y: this.indexingStartY }, { x: newX, y: endIindexing1.y })
     }
-    if(startInfo.count == PhotoIndex.count && startInfo.itemIndex == PhotoIndex.itemIndex ){//同数量 同item
-
+    let ceY = PhotoIndex.itemIndex == 0?(mouseY - coordinate.y):(coordinate.y + coordinate.height -mouseY)
+    if(startInfo.count == PhotoIndex.count && startInfo.itemIndex == PhotoIndex.itemIndex && (mouseX-coordinate.x)>ceY){//同数量 同item
+      console.log(startInfo, endIindexing1, coordinate,'坐标',mouseX,mouseY)
+      let newY = PhotoIndex.itemIndex == 0 ? (coordinate.y - 30) : (coordinate.y + coordinate.height + 80)
+      points.splice(1, 0, { x: this.indexingStartX, y: newY }, { x: mouseX, y: newY })
     }
     this.tempArrow.start = null
     this.tempArrow.end = null
@@ -570,6 +578,12 @@ export class CanvasPhotoEditor {
       let newX = addPage*(this.pageWidth + this.pageMargin)
       newpPoints.splice(1, 0, { x: newX, y: start.y }, { x: newX, y: end.y })
     }
+    // let ceY = PhotoIndex.itemIndex == 0?(mouseY - coordinate.y):(coordinate.y + coordinate.height -mouseY)
+    // if(start.count == end.count && start.itemIndex == end.itemIndex && (mouseX-coordinate.x)>ceY){//同数量 同item
+    //   console.log(startInfo, endIindexing1, coordinate,'坐标',mouseX,mouseY)
+    //   let newY = PhotoIndex.itemIndex == 0 ? (coordinate.y - 30) : (coordinate.y + coordinate.height + 80)
+    //   points.splice(1, 0, { x: this.indexingStartX, y: newY }, { x: mouseX, y: newY })
+    // }
     ctx.strokeStyle = color;
     ctx.fillStyle = color;
     ctx.lineWidth = lineWidth;
@@ -623,8 +637,12 @@ export class CanvasPhotoEditor {
     // 绘制T边
     let startInfo = indexingList[0]
     let endInfo = indexingList[1]
+    console.log('drawGuideLine', indexingList)
     ctx.beginPath();
-    if (startInfo.pageIndex == endInfo.pageIndex) {//判断上下就行
+    if (startInfo.count == endInfo.count && startInfo.count == 2 && startInfo.itemIndex == endInfo.itemIndex) {
+      ctx.moveTo(coordinate.x, last.y);
+      ctx.lineTo((coordinate.x + coordinate.width), last.y);
+    } else if (startInfo.pageIndex == endInfo.pageIndex) {//判断上下就行
       ctx.moveTo(coordinate.x, last.y);
       ctx.lineTo((coordinate.x + coordinate.width), last.y
     );