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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kfb-view",
3
3
  "description": "一个在线kfb的阅片软件",
4
- "version": "2.2.3",
4
+ "version": "2.2.4",
5
5
  "author": "qifeng.fan <qifeng.fan@hzztai.com>",
6
6
  "license": "MIT",
7
7
  "main": "lib/kfb-view.js",
@@ -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 label = this.movePoint.label;
262
- this.$emit(EVENT_AREA_MOVE_END, label);
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
- if (tool === POLYGON) {
152
- this[tool].drawPoints(points, {
153
- radius: this.options.thumb.radius,
154
- strokeStyle: this.options.thumb.color,
155
- fillStyle: this.options.thumb.bgColor,
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
- if (tool === POLYGON) {
189
- this[tool].drawPoints(points, {
190
- radius: this.options.thumb.radius,
191
- strokeStyle: this.options.thumb.color,
192
- fillStyle: this.options.thumb.bgColor,
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 (point.x === this.points[0].x && point.y === this.points[0].y &&
213
- !NO_NORMAL_REGION_TYPES.includes(tool)) {
214
- this.points = [];
215
- return;
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
- if (tool === POLYGON) {
309
- this[tool].drawPoints(points, {
310
- radius: this.options.thumb.radius,
311
- strokeStyle: this.options.thumb.color,
312
- fillStyle: this.options.thumb.bgColor,
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
- if (this.tool === POLYGON) {
426
- this[this.tool].drawPoints(points, {
427
- radius: this.options.thumb.radius,
428
- strokeStyle: this.options.thumb.color,
429
- fillStyle: this.options.thumb.bgColor,
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.clearRect(0, 0, 20, this.canvas.height);
79
- ctx.clearRect(0, 0, this.canvas.width, 20);
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.clearRect(0, 0, 20, 20);
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
@@ -46,6 +46,12 @@ class Brush {
46
46
  this.thumb.draw(point, config);
47
47
  }
48
48
 
49
+ drawPoints(points, config) {
50
+ points.forEach((point) => {
51
+ this.drawThumb(point, config);
52
+ });
53
+ }
54
+
49
55
  /**
50
56
  * 画笔具体操作
51
57
  * @param {Object[]} points - 绘制的点
@@ -27,12 +27,6 @@ class Polygon extends Brush {
27
27
  }
28
28
  }
29
29
  }
30
-
31
- drawPoints(points, config) {
32
- points.forEach((point) => {
33
- this.drawThumb(point, config);
34
- });
35
- }
36
30
  }
37
31
 
38
32
  export {
package/src/view.js CHANGED
@@ -245,6 +245,7 @@ function initNavigator(kv) {
245
245
  containerHeight: config.height,
246
246
  containerWidth: config.width,
247
247
  element: navigator,
248
+ scale: config.scale,
248
249
  ...config.navigator,
249
250
  });
250
251
  }