@inweb/markup 25.8.16 → 25.8.19
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/dist/markup.js +29 -4
- package/dist/markup.js.map +1 -1
- package/dist/markup.min.js +1 -1
- package/dist/markup.module.js +20 -4
- package/dist/markup.module.js.map +1 -1
- package/lib/markup/IMarkup.d.ts +33 -29
- package/lib/markup/IMarkupLine.d.ts +1 -1
- package/lib/markup/IWorldTransform.d.ts +2 -2
- package/lib/markup/Konva/KonvaImage.d.ts +3 -0
- package/package.json +3 -3
- package/src/markup/IMarkup.ts +33 -29
- package/src/markup/IMarkupLine.ts +1 -1
- package/src/markup/IWorldTransform.ts +2 -2
- package/src/markup/Konva/KonvaImage.ts +33 -4
- package/src/markup/Konva/KonvaMarkup.ts +2 -0
package/dist/markup.module.js
CHANGED
|
@@ -593,10 +593,11 @@ class KonvaImage {
|
|
|
593
593
|
constructor(params, ref = null) {
|
|
594
594
|
var _a, _b;
|
|
595
595
|
this._ratio = 1;
|
|
596
|
+
this.EPSILON = 1e-5;
|
|
596
597
|
if (ref) {
|
|
597
598
|
this._ref = ref;
|
|
598
599
|
this._canvasImage = ref.image();
|
|
599
|
-
this._ratio = this._ref.height()
|
|
600
|
+
this._ratio = this._ref.height() <= this.EPSILON || this._ref.width() <= this.EPSILON ? 1 : this._ref.height() / this._ref.width();
|
|
600
601
|
return;
|
|
601
602
|
}
|
|
602
603
|
if (!params || !params.position || !params.src) return;
|
|
@@ -611,9 +612,22 @@ class KonvaImage {
|
|
|
611
612
|
});
|
|
612
613
|
this._canvasImage.onload = () => {
|
|
613
614
|
this._ref.image(this._canvasImage);
|
|
614
|
-
if (this._ref.height()
|
|
615
|
-
if (this._ref.width()
|
|
616
|
-
this._ratio = this._ref.height()
|
|
615
|
+
if (this._ref.height() <= this.EPSILON) this._ref.height(this._canvasImage.height);
|
|
616
|
+
if (this._ref.width() <= this.EPSILON) this._ref.width(this._canvasImage.width);
|
|
617
|
+
this._ratio = this._ref.height() <= this.EPSILON || this._ref.width() <= this.EPSILON ? 1 : this._ref.height() / this._ref.width();
|
|
618
|
+
if ((params.width <= this.EPSILON || params.height <= this.EPSILON) && (params.maxWidth >= this.EPSILON || params.maxWidth >= this.EPSILON)) {
|
|
619
|
+
const heightOutOfCanvas = params.maxHeight - this._canvasImage.height;
|
|
620
|
+
const widthOutOfCanvas = params.maxWidth - this._canvasImage.width;
|
|
621
|
+
if (heightOutOfCanvas <= this.EPSILON || widthOutOfCanvas <= this.EPSILON) {
|
|
622
|
+
if (widthOutOfCanvas <= this.EPSILON && widthOutOfCanvas < heightOutOfCanvas / this._ratio) {
|
|
623
|
+
this._ref.height(params.maxWidth * this._ratio);
|
|
624
|
+
this._ref.width(params.maxWidth);
|
|
625
|
+
} else {
|
|
626
|
+
this._ref.width(params.maxHeight / this._ratio);
|
|
627
|
+
this._ref.height(params.maxHeight);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
617
631
|
};
|
|
618
632
|
this._canvasImage.src = params.src;
|
|
619
633
|
this._ref.on("transform", (e => {
|
|
@@ -1710,6 +1724,8 @@ class KonvaMarkup {
|
|
|
1710
1724
|
src: src,
|
|
1711
1725
|
width: width,
|
|
1712
1726
|
height: height,
|
|
1727
|
+
maxWidth: this._konvaStage.width() - position.x,
|
|
1728
|
+
maxHeight: this._konvaStage.height() - position.y,
|
|
1713
1729
|
id: id
|
|
1714
1730
|
});
|
|
1715
1731
|
this.addObject(konvaImage);
|