kfb-view 3.0.6 → 3.0.8
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 +69 -41
- package/config/webpack.dev.conf.js +3 -3
- package/example/index.js +20 -52
- package/lib/kfb-view.js +1 -1
- package/package.json +1 -1
- package/src/components/grid/index.js +8 -3
- package/src/view.js +2 -1
package/package.json
CHANGED
|
@@ -26,7 +26,11 @@ export class Grid extends ViewerCommon {
|
|
|
26
26
|
const imageViewYEndPoint = this.viewerElementToImageCoordinates(0,
|
|
27
27
|
this.canvas.height);
|
|
28
28
|
let currentZoom = this.getImageZoom(true) * this.options.scale;
|
|
29
|
-
|
|
29
|
+
const pxConversion = this.options.pxConversion ?
|
|
30
|
+
this.options.imageCapRes : 1;
|
|
31
|
+
let baseScale = this.options.scale === 40 ?
|
|
32
|
+
(this.options.pxConversion ? 1600 / this.options.imageCapRes : 3200) :
|
|
33
|
+
(this.options.pxConversion ? 800 / this.options.imageCapRes : 1600);
|
|
30
34
|
let twoCount = 0;
|
|
31
35
|
if (currentZoom >= 1) {
|
|
32
36
|
while (currentZoom / 2 >= 1) {
|
|
@@ -91,7 +95,8 @@ export class Grid extends ViewerCommon {
|
|
|
91
95
|
ctx.moveTo(point.x + (basePx / 5) * j, 16);
|
|
92
96
|
ctx.lineTo(point.x + (basePx / 5) * j, 20);
|
|
93
97
|
if (i !== minX) {
|
|
94
|
-
ctx.fillText(i * baseScale, point.x + 5,
|
|
98
|
+
ctx.fillText((i * baseScale * pxConversion).toFixed(0), point.x + 5,
|
|
99
|
+
13);
|
|
95
100
|
}
|
|
96
101
|
}
|
|
97
102
|
}
|
|
@@ -106,7 +111,7 @@ export class Grid extends ViewerCommon {
|
|
|
106
111
|
ctx.save();
|
|
107
112
|
ctx.translate(3, point.y + 5);
|
|
108
113
|
ctx.rotate(Math.PI / 2);
|
|
109
|
-
ctx.fillText(i * baseScale, 0, 0);
|
|
114
|
+
ctx.fillText((i * baseScale * pxConversion).toFixed(0), 0, 0);
|
|
110
115
|
ctx.restore();
|
|
111
116
|
}
|
|
112
117
|
}
|
package/src/view.js
CHANGED
|
@@ -68,6 +68,7 @@ export default class KfbView extends EventEmitter {
|
|
|
68
68
|
* @param {boolean=} config.grid.disabled 是否禁用网格线
|
|
69
69
|
* @param {boolean=} config.grid.show 是否显示网格线
|
|
70
70
|
* @param {boolean=} config.grid.ruler 是否启用标尺
|
|
71
|
+
* @param {boolean=} config.grid.pxConversion 是否启用标尺
|
|
71
72
|
* @param {function=} config.measure.handler 标注信息的回调处理
|
|
72
73
|
* @param {function=} config.measure.selectHandler 标注信息选中时的回调处理
|
|
73
74
|
* @param {boolean=} config.measure.color 标注注释颜色
|
|
@@ -352,8 +353,8 @@ function initEvent(kv) {
|
|
|
352
353
|
});
|
|
353
354
|
// 键盘事件会连续触发两次
|
|
354
355
|
kv.viewer.addHandler('canvas-key', delayedTrigger((e) => {
|
|
355
|
-
e.preventDefaultAction = true;
|
|
356
356
|
const {originalEvent} = e;
|
|
357
|
+
e.preventDefaultAction = originalEvent.key.indexOf('Arrow') === -1;
|
|
357
358
|
handlerCacheEvent(originalEvent, kv);
|
|
358
359
|
if (kv.board?.isInDraw) {
|
|
359
360
|
kv.board?.onCanvasKey?.(e);
|