kfb-view 3.0.3 → 3.0.5
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 +47 -40
- package/example/index.js +4 -4
- package/lib/kfb-view.js +1 -1
- package/package.json +1 -1
- package/src/components/navigator/index.js +15 -15
- package/src/components/tailoring/index.js +18 -2
package/package.json
CHANGED
|
@@ -325,19 +325,19 @@ export class Navigator extends EventEmitter {
|
|
|
325
325
|
const imgHeight = img.height;
|
|
326
326
|
let scale = 1;
|
|
327
327
|
if (imgWidth >= imgHeight) {
|
|
328
|
-
scale = imgHeight / this.height;
|
|
329
|
-
const trueWidth = imgWidth / scale;
|
|
330
|
-
canvas.height = this.height;
|
|
331
|
-
canvas.width = trueWidth;
|
|
332
|
-
ctx.drawImage(img, 0, 0, trueWidth, canvas.height);
|
|
333
|
-
}
|
|
334
|
-
if (imgHeight > imgWidth) {
|
|
335
328
|
scale = imgWidth / this.width;
|
|
336
329
|
const trueHeight = imgHeight / scale;
|
|
337
330
|
canvas.width = this.width;
|
|
338
331
|
canvas.height = trueHeight;
|
|
339
332
|
ctx.drawImage(img, 0, 0, canvas.width, trueHeight);
|
|
340
333
|
}
|
|
334
|
+
if (imgHeight > imgWidth) {
|
|
335
|
+
scale = imgHeight / this.height;
|
|
336
|
+
const trueWidth = imgWidth / scale;
|
|
337
|
+
canvas.height = this.height;
|
|
338
|
+
canvas.width = trueWidth;
|
|
339
|
+
ctx.drawImage(img, 0, 0, trueWidth, canvas.height);
|
|
340
|
+
}
|
|
341
341
|
this.setViewRect(this.element.getElementsByClassName('view-rect')[0]);
|
|
342
342
|
const colorCanvas = this.element.getElementsByClassName(
|
|
343
343
|
'navigator-color-rect')[0];
|
|
@@ -358,14 +358,6 @@ export class Navigator extends EventEmitter {
|
|
|
358
358
|
const imgHeight = img.height;
|
|
359
359
|
let scale = 1;
|
|
360
360
|
if (imgWidth >= imgHeight) {
|
|
361
|
-
scale = imgHeight / this.height;
|
|
362
|
-
const trueWidth = imgWidth / scale;
|
|
363
|
-
this.canvas.height = this.height;
|
|
364
|
-
this.canvas.width = trueWidth;
|
|
365
|
-
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
366
|
-
ctx.drawImage(img, 0, 0, trueWidth, this.canvas.height);
|
|
367
|
-
}
|
|
368
|
-
if (imgHeight > imgWidth) {
|
|
369
361
|
scale = imgWidth / this.width;
|
|
370
362
|
const trueHeight = imgHeight / scale;
|
|
371
363
|
this.canvas.width = this.width;
|
|
@@ -373,6 +365,14 @@ export class Navigator extends EventEmitter {
|
|
|
373
365
|
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
374
366
|
ctx.drawImage(img, 0, 0, this.canvas.width, trueHeight);
|
|
375
367
|
}
|
|
368
|
+
if (imgHeight > imgWidth) {
|
|
369
|
+
scale = imgHeight / this.height;
|
|
370
|
+
const trueWidth = imgWidth / scale;
|
|
371
|
+
this.canvas.height = this.height;
|
|
372
|
+
this.canvas.width = trueWidth;
|
|
373
|
+
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
374
|
+
ctx.drawImage(img, 0, 0, trueWidth, this.canvas.height);
|
|
375
|
+
}
|
|
376
376
|
this.setViewRect(this.element.getElementsByClassName('view-rect')[0]);
|
|
377
377
|
const colorCanvas = this.element.getElementsByClassName(
|
|
378
378
|
'navigator-color-rect')[0];
|
|
@@ -56,7 +56,15 @@ export class Tailoring extends ViewerCommon {
|
|
|
56
56
|
pointList[6],
|
|
57
57
|
pointList[8]];
|
|
58
58
|
if (now) {
|
|
59
|
-
this
|
|
59
|
+
this.emitTailoringRegion();
|
|
60
|
+
this.$emit(EVENT_TAILORING_SCREENSHOT, {
|
|
61
|
+
base64: this.getScreenCanvasImage(),
|
|
62
|
+
region: this.viewerElementToImageRectangle({
|
|
63
|
+
x: this.tailoringPoints[0].x, y: this.tailoringPoints[0].y,
|
|
64
|
+
width: this.tailoringPoints[3].x - this.tailoringPoints[0].x,
|
|
65
|
+
height: this.tailoringPoints[3].y - this.tailoringPoints[0].y,
|
|
66
|
+
}),
|
|
67
|
+
});
|
|
60
68
|
this.stopTailoring();
|
|
61
69
|
} else {
|
|
62
70
|
this.color = color || '#FFF';
|
|
@@ -253,7 +261,15 @@ export class Tailoring extends ViewerCommon {
|
|
|
253
261
|
|
|
254
262
|
onCanvasDblClick(position) {
|
|
255
263
|
if (this.tailoringPoints.length > 0 && this.isPointInMatrix(position)) {
|
|
256
|
-
this
|
|
264
|
+
this.emitTailoringRegion();
|
|
265
|
+
this.$emit(EVENT_TAILORING_SCREENSHOT, {
|
|
266
|
+
base64: this.getScreenCanvasImage(),
|
|
267
|
+
region: this.viewerElementToImageRectangle({
|
|
268
|
+
x: this.tailoringPoints[0].x, y: this.tailoringPoints[0].y,
|
|
269
|
+
width: this.tailoringPoints[3].x - this.tailoringPoints[0].x,
|
|
270
|
+
height: this.tailoringPoints[3].y - this.tailoringPoints[0].y,
|
|
271
|
+
}),
|
|
272
|
+
});
|
|
257
273
|
}
|
|
258
274
|
this.stopTailoring();
|
|
259
275
|
}
|