kfb-view 2.2.3 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/workspace.xml +30 -20
- package/example/index.js +3 -4
- package/lib/kfb-view.js +1 -1
- package/package.json +1 -1
- package/src/components/area/index.js +9 -2
- package/src/components/board/index.js +30 -32
- package/src/components/grid/index.js +8 -5
- package/src/components/navigator/index.js +0 -10
- package/src/tool/Brush.js +6 -0
- package/src/tool/Polygon.js +0 -6
- package/src/view.js +1 -0
package/package.json
CHANGED
|
@@ -39,6 +39,7 @@ export class Area extends ViewerCommon {
|
|
|
39
39
|
super(viewer, canvas, cache, options);
|
|
40
40
|
this.labelList = [];
|
|
41
41
|
this.movePoint = undefined;
|
|
42
|
+
this.currentPressPoint = undefined;
|
|
42
43
|
this.lastPoint = undefined;
|
|
43
44
|
this.draging = false;
|
|
44
45
|
MARKS.forEach((mark) => {
|
|
@@ -82,6 +83,7 @@ export class Area extends ViewerCommon {
|
|
|
82
83
|
*/
|
|
83
84
|
onCanvasPress({x, y}) {
|
|
84
85
|
this.movePoint = undefined;
|
|
86
|
+
this.currentPressPoint = undefined;
|
|
85
87
|
this.lastPoint = undefined;
|
|
86
88
|
this.draging = false;
|
|
87
89
|
let selectList = [];
|
|
@@ -181,6 +183,7 @@ export class Area extends ViewerCommon {
|
|
|
181
183
|
// moveIndex>-1,表示选中的是图形中可移动的点
|
|
182
184
|
if (~moveIndex) {
|
|
183
185
|
this.movePoint = {position: moveIndex, label: item};
|
|
186
|
+
this.currentPressPoint = {x, y};
|
|
184
187
|
} else if ((item.tool !== POLYGON &&
|
|
185
188
|
isPointInMatrix(pointList[0], pointList[2], pointList[6], pointList[8],
|
|
186
189
|
{x, y})) ||
|
|
@@ -258,10 +261,14 @@ export class Area extends ViewerCommon {
|
|
|
258
261
|
*/
|
|
259
262
|
onCanvasRelease({x, y}) {
|
|
260
263
|
if (this.movePoint && this.options.drag !== false) {
|
|
261
|
-
const
|
|
262
|
-
|
|
264
|
+
const dist = getDistance(this.currentPressPoint, {x, y});
|
|
265
|
+
if (Math.abs(dist) > 1) {
|
|
266
|
+
const label = this.movePoint.label;
|
|
267
|
+
this.$emit(EVENT_AREA_MOVE_END, label);
|
|
268
|
+
}
|
|
263
269
|
}
|
|
264
270
|
this.movePoint = undefined;
|
|
271
|
+
this.currentPressPoint = undefined;
|
|
265
272
|
this.lastPoint = undefined;
|
|
266
273
|
this.draging = false;
|
|
267
274
|
this.change();
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
EVENT_IN_PAINTING,
|
|
12
12
|
} from '../../const/event';
|
|
13
13
|
import {
|
|
14
|
+
getDistance,
|
|
14
15
|
pointInOtherPoint,
|
|
15
16
|
pointsToRegion,
|
|
16
17
|
} from '../../util/calculate';
|
|
@@ -148,13 +149,11 @@ export class Board extends ViewerCommon {
|
|
|
148
149
|
const points = this.imageToViewerElementPoints(this.points);
|
|
149
150
|
this[tool].draw(points);
|
|
150
151
|
this[tool].endDraw();
|
|
151
|
-
|
|
152
|
-
this
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
});
|
|
157
|
-
}
|
|
152
|
+
this[tool].drawPoints(points, {
|
|
153
|
+
radius: this.options.thumb.radius,
|
|
154
|
+
strokeStyle: this.options.thumb.color,
|
|
155
|
+
fillStyle: this.options.thumb.bgColor,
|
|
156
|
+
});
|
|
158
157
|
this.$emit(EVENT_START_PAINTING, this.getPaintOptions());
|
|
159
158
|
}
|
|
160
159
|
|
|
@@ -185,13 +184,11 @@ export class Board extends ViewerCommon {
|
|
|
185
184
|
const points = this.imageToViewerElementPoints(this.points);
|
|
186
185
|
this[tool].draw(points);
|
|
187
186
|
this[tool].endDraw();
|
|
188
|
-
|
|
189
|
-
this
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
});
|
|
194
|
-
}
|
|
187
|
+
this[tool].drawPoints(points, {
|
|
188
|
+
radius: this.options.thumb.radius,
|
|
189
|
+
strokeStyle: this.options.thumb.color,
|
|
190
|
+
fillStyle: this.options.thumb.bgColor,
|
|
191
|
+
});
|
|
195
192
|
this.$emit(EVENT_IN_PAINTING, this.getPaintOptions());
|
|
196
193
|
}
|
|
197
194
|
|
|
@@ -209,10 +206,15 @@ export class Board extends ViewerCommon {
|
|
|
209
206
|
return;
|
|
210
207
|
}
|
|
211
208
|
const tool = this.tool;
|
|
212
|
-
if (
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
209
|
+
if (!NO_NORMAL_REGION_TYPES.includes(tool)) {
|
|
210
|
+
const firstPoint = this.imageToViewerElementCoordinates(this.points[0].x,
|
|
211
|
+
this.points[0].y);
|
|
212
|
+
const dist = getDistance(firstPoint, {x, y});
|
|
213
|
+
if (Math.abs(dist) < 10) {
|
|
214
|
+
this.points = [];
|
|
215
|
+
this.clearCanvas();
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
216
218
|
} else if (POINT_TYPES.includes(tool)) {
|
|
217
219
|
this.points = [point, point];
|
|
218
220
|
} else if (tool === POLYGON) {
|
|
@@ -305,13 +307,11 @@ export class Board extends ViewerCommon {
|
|
|
305
307
|
const points = this.imageToViewerElementPoints(this.points);
|
|
306
308
|
this[tool].draw(points);
|
|
307
309
|
this[tool].endDraw();
|
|
308
|
-
|
|
309
|
-
this
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
});
|
|
314
|
-
}
|
|
310
|
+
this[tool].drawPoints(points, {
|
|
311
|
+
radius: this.options.thumb.radius,
|
|
312
|
+
strokeStyle: this.options.thumb.color,
|
|
313
|
+
fillStyle: this.options.thumb.bgColor,
|
|
314
|
+
});
|
|
315
315
|
this.$emit(EVENT_IN_PAINTING, this.getPaintOptions());
|
|
316
316
|
}
|
|
317
317
|
}
|
|
@@ -422,13 +422,11 @@ export class Board extends ViewerCommon {
|
|
|
422
422
|
this[this.tool].startDraw();
|
|
423
423
|
this[this.tool].draw(points);
|
|
424
424
|
this[this.tool].endDraw();
|
|
425
|
-
|
|
426
|
-
this
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
});
|
|
431
|
-
}
|
|
425
|
+
this[this.tool].drawPoints(points, {
|
|
426
|
+
radius: this.options.thumb.radius,
|
|
427
|
+
strokeStyle: this.options.thumb.color,
|
|
428
|
+
fillStyle: this.options.thumb.bgColor,
|
|
429
|
+
});
|
|
432
430
|
this.$emit(EVENT_IN_PAINTING, this.getPaintOptions());
|
|
433
431
|
}
|
|
434
432
|
}
|
|
@@ -72,11 +72,13 @@ export class Grid extends ViewerCommon {
|
|
|
72
72
|
const basePx = this.imageToViewerElementCoordinates(baseScale, 0).
|
|
73
73
|
minus(this.imageToViewerElementCoordinates(0, 0)).x;
|
|
74
74
|
ctx.beginPath();
|
|
75
|
-
ctx.strokeStyle = 'rgba(0, 0, 0, .8)';
|
|
76
|
-
ctx.fillStyle = 'rgba(0, 0, 0, .3)';
|
|
77
75
|
ctx.font = '14px Arial';
|
|
78
|
-
ctx.
|
|
79
|
-
ctx.
|
|
76
|
+
ctx.fillStyle = '#fff';
|
|
77
|
+
ctx.fillRect(0, 0, 20, this.canvas.height);
|
|
78
|
+
ctx.fillRect(0, 0, this.canvas.width, 20);
|
|
79
|
+
ctx.beginPath();
|
|
80
|
+
ctx.fillStyle = 'rgba(0, 0, 0, .3)';
|
|
81
|
+
ctx.strokeStyle = 'rgba(0, 0, 0, .8)';
|
|
80
82
|
ctx.moveTo(20, 20);
|
|
81
83
|
ctx.lineTo(20, this.canvas.height);
|
|
82
84
|
ctx.moveTo(20, 20);
|
|
@@ -111,7 +113,8 @@ export class Grid extends ViewerCommon {
|
|
|
111
113
|
}
|
|
112
114
|
ctx.stroke();
|
|
113
115
|
ctx.beginPath();
|
|
114
|
-
ctx.
|
|
116
|
+
ctx.fillStyle = '#fff';
|
|
117
|
+
ctx.fillRect(0, 0, 20, 20);
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
120
|
}
|
|
@@ -381,14 +381,4 @@ export class Navigator extends EventEmitter {
|
|
|
381
381
|
};
|
|
382
382
|
img.src = this.options.thumbnail; // 设置图片源地
|
|
383
383
|
}
|
|
384
|
-
|
|
385
|
-
toggleNavigator() {
|
|
386
|
-
const navigatorMain = this.element.getElementsByClassName(
|
|
387
|
-
'navigator-main')[0];
|
|
388
|
-
if (navigatorMain.style.display === 'none') {
|
|
389
|
-
navigatorMain.style.display = 'block';
|
|
390
|
-
} else {
|
|
391
|
-
navigatorMain.style.display = 'none';
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
384
|
}
|
package/src/tool/Brush.js
CHANGED
package/src/tool/Polygon.js
CHANGED