|
@@ -265,7 +265,9 @@ export class CanvasPhotoEditor {
|
|
|
const mouseX = (e.clientX - rect.left - this.drawOffsetX) / this.scale
|
|
const mouseX = (e.clientX - rect.left - this.drawOffsetX) / this.scale
|
|
|
const mouseY = (e.clientY - rect.top - this.drawOffsetY) / this.scale
|
|
const mouseY = (e.clientY - rect.top - this.drawOffsetY) / this.scale
|
|
|
if (this.indexing && drawing) {
|
|
if (this.indexing && drawing) {
|
|
|
- this.tempArrow.end = {x: mouseX, y: mouseY }
|
|
|
|
|
|
|
+ const PhotoIndex = this.getPhotoPositionInPage(e)
|
|
|
|
|
+ console.log('PhotoIndex', PhotoIndex, this.tempArrow)
|
|
|
|
|
+ this.tempArrow.end = {...PhotoIndex, x: mouseX, y: mouseY }
|
|
|
this.drawAllPages()
|
|
this.drawAllPages()
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -441,7 +443,7 @@ export class CanvasPhotoEditor {
|
|
|
this.indexingList.push(PhotoIndex)
|
|
this.indexingList.push(PhotoIndex)
|
|
|
this.indexingStartX = mouseX
|
|
this.indexingStartX = mouseX
|
|
|
this.indexingStartY = mouseY
|
|
this.indexingStartY = mouseY
|
|
|
- this.tempArrow.start = { x: mouseX, y: mouseY }
|
|
|
|
|
|
|
+ this.tempArrow.start = { ...PhotoIndex, x: mouseX, y: mouseY }
|
|
|
this.tempArrow.drawing = true;
|
|
this.tempArrow.drawing = true;
|
|
|
console.log('indexing', this.indexing, PhotoIndex, mouseX, mouseY)
|
|
console.log('indexing', this.indexing, PhotoIndex, mouseX, mouseY)
|
|
|
}
|
|
}
|
|
@@ -476,12 +478,19 @@ export class CanvasPhotoEditor {
|
|
|
this.indexingEndY = mouseY
|
|
this.indexingEndY = mouseY
|
|
|
let startInfo = this.indexingList[0]
|
|
let startInfo = this.indexingList[0]
|
|
|
this.indexingList.push(PhotoIndex)
|
|
this.indexingList.push(PhotoIndex)
|
|
|
|
|
+
|
|
|
let endIindexing1 = {//默认同页面
|
|
let endIindexing1 = {//默认同页面
|
|
|
- x: this.indexingEndX,
|
|
|
|
|
|
|
+ x: this.indexingStartX,
|
|
|
y: startInfo.itemIndex > PhotoIndex.itemIndex ? (coordinate.y + coordinate.height) : coordinate.y,
|
|
y: startInfo.itemIndex > PhotoIndex.itemIndex ? (coordinate.y + coordinate.height) : coordinate.y,
|
|
|
}
|
|
}
|
|
|
- if (startInfo.pageIndex != PhotoIndex.pageIndex) {
|
|
|
|
|
- endIindexing1 = {//默认同页面
|
|
|
|
|
|
|
+ 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) : coordinate.x,
|
|
|
|
|
+ y: this.indexingStartY,
|
|
|
|
|
+ }
|
|
|
|
|
+ }else if(startInfo.pageIndex != PhotoIndex.pageIndex){
|
|
|
|
|
+ endIindexing1 = {//不同同item页面
|
|
|
x: startInfo.pageIndex > PhotoIndex.pageIndex ? (coordinate.x + coordinate.width) : coordinate.x,
|
|
x: startInfo.pageIndex > PhotoIndex.pageIndex ? (coordinate.x + coordinate.width) : coordinate.x,
|
|
|
y: this.indexingEndY,
|
|
y: this.indexingEndY,
|
|
|
}
|
|
}
|
|
@@ -490,7 +499,7 @@ export class CanvasPhotoEditor {
|
|
|
x: this.indexingStartX,
|
|
x: this.indexingStartX,
|
|
|
y: this.indexingStartY,
|
|
y: this.indexingStartY,
|
|
|
}, endIindexing1]
|
|
}, endIindexing1]
|
|
|
- if(PhotoIndex.pageIndex != oldPhotoIndex.pageIndex && Math.abs(this.indexingStartY - endIindexing1.y)>this.rqHeight){//需要折现换行
|
|
|
|
|
|
|
+ if(PhotoIndex.pageIndex != oldPhotoIndex.pageIndex && (startInfo.count != PhotoIndex.count || startInfo.itemIndex != PhotoIndex.itemIndex)){//需要折现换行
|
|
|
let addPage = PhotoIndex.pageIndex>oldPhotoIndex.pageIndex?PhotoIndex.pageIndex:oldPhotoIndex.pageIndex
|
|
let addPage = PhotoIndex.pageIndex>oldPhotoIndex.pageIndex?PhotoIndex.pageIndex:oldPhotoIndex.pageIndex
|
|
|
let newX = addPage*(this.pageWidth + this.pageMargin)
|
|
let newX = addPage*(this.pageWidth + this.pageMargin)
|
|
|
points.splice(1, 0, { x: newX, y: this.indexingStartY }, { x: newX, y: endIindexing1.y })
|
|
points.splice(1, 0, { x: newX, y: this.indexingStartY }, { x: newX, y: endIindexing1.y })
|
|
@@ -524,6 +533,9 @@ export class CanvasPhotoEditor {
|
|
|
|
|
|
|
|
// 绘制临时标引
|
|
// 绘制临时标引
|
|
|
drawInterimLine(points) {//val 不是重绘才保存历史记录,否则是重绘就不保存了
|
|
drawInterimLine(points) {//val 不是重绘才保存历史记录,否则是重绘就不保存了
|
|
|
|
|
+ console.log('drawInterimLine', ...points)
|
|
|
|
|
+ let newpPoints = [...points]
|
|
|
|
|
+
|
|
|
const ctx = this.ctx;
|
|
const ctx = this.ctx;
|
|
|
let color = '#ff0000';
|
|
let color = '#ff0000';
|
|
|
let lineWidth = 2;
|
|
let lineWidth = 2;
|
|
@@ -535,7 +547,13 @@ export class CanvasPhotoEditor {
|
|
|
ctx.scale(this.scale, this.scale);
|
|
ctx.scale(this.scale, this.scale);
|
|
|
|
|
|
|
|
if (points.length < 2) return;
|
|
if (points.length < 2) return;
|
|
|
-
|
|
|
|
|
|
|
+ let start = points[0]
|
|
|
|
|
+ let end = points[1]
|
|
|
|
|
+ if(start.pageIndex != end.pageIndex && end.itemIndex != -1 && !(start.count == end.count && start.itemIndex == end.itemIndex)){//同页码 同item
|
|
|
|
|
+ let addPage = end.pageIndex>start.pageIndex?end.pageIndex:start.pageIndex
|
|
|
|
|
+ let newX = addPage*(this.pageWidth + this.pageMargin)
|
|
|
|
|
+ newpPoints.splice(1, 0, { x: newX, y: start.y }, { x: newX, y: end.y })
|
|
|
|
|
+ }
|
|
|
ctx.strokeStyle = color;
|
|
ctx.strokeStyle = color;
|
|
|
ctx.fillStyle = color;
|
|
ctx.fillStyle = color;
|
|
|
ctx.lineWidth = lineWidth;
|
|
ctx.lineWidth = lineWidth;
|
|
@@ -544,9 +562,9 @@ export class CanvasPhotoEditor {
|
|
|
|
|
|
|
|
// 绘制折线
|
|
// 绘制折线
|
|
|
ctx.beginPath();
|
|
ctx.beginPath();
|
|
|
- ctx.moveTo(points[0].x, points[0].y);
|
|
|
|
|
- for (let i = 1; i < points.length; i++) {
|
|
|
|
|
- ctx.lineTo(points[i].x, points[i].y);
|
|
|
|
|
|
|
+ ctx.moveTo(newpPoints[0].x, newpPoints[0].y);
|
|
|
|
|
+ for (let i = 1; i < newpPoints.length; i++) {
|
|
|
|
|
+ ctx.lineTo(newpPoints[i].x, newpPoints[i].y);
|
|
|
}
|
|
}
|
|
|
ctx.stroke();
|
|
ctx.stroke();
|
|
|
ctx.restore();
|
|
ctx.restore();
|