@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.js
CHANGED
|
@@ -12091,11 +12091,15 @@
|
|
|
12091
12091
|
constructor(params, ref = null) {
|
|
12092
12092
|
var _a, _b;
|
|
12093
12093
|
this._ratio = 1;
|
|
12094
|
+
this.EPSILON = 10e-6;
|
|
12094
12095
|
if (ref) {
|
|
12095
12096
|
// if (ref.height() === 0 || ref.width() === 0) return;
|
|
12096
12097
|
this._ref = ref;
|
|
12097
12098
|
this._canvasImage = ref.image();
|
|
12098
|
-
this._ratio =
|
|
12099
|
+
this._ratio =
|
|
12100
|
+
this._ref.height() <= this.EPSILON || this._ref.width() <= this.EPSILON
|
|
12101
|
+
? 1
|
|
12102
|
+
: this._ref.height() / this._ref.width();
|
|
12099
12103
|
return;
|
|
12100
12104
|
}
|
|
12101
12105
|
if (!params || !params.position || !params.src)
|
|
@@ -12111,11 +12115,30 @@
|
|
|
12111
12115
|
});
|
|
12112
12116
|
this._canvasImage.onload = () => {
|
|
12113
12117
|
this._ref.image(this._canvasImage);
|
|
12114
|
-
if (this._ref.height()
|
|
12118
|
+
if (this._ref.height() <= this.EPSILON)
|
|
12115
12119
|
this._ref.height(this._canvasImage.height);
|
|
12116
|
-
if (this._ref.width()
|
|
12120
|
+
if (this._ref.width() <= this.EPSILON)
|
|
12117
12121
|
this._ref.width(this._canvasImage.width);
|
|
12118
|
-
this._ratio =
|
|
12122
|
+
this._ratio =
|
|
12123
|
+
this._ref.height() <= this.EPSILON || this._ref.width() <= this.EPSILON
|
|
12124
|
+
? 1
|
|
12125
|
+
: this._ref.height() / this._ref.width();
|
|
12126
|
+
// need to rescale only if input width and height are 0 - we do not loading Viewpoint with existing params
|
|
12127
|
+
if ((params.width <= this.EPSILON || params.height <= this.EPSILON) &&
|
|
12128
|
+
(params.maxWidth >= this.EPSILON || params.maxWidth >= this.EPSILON)) {
|
|
12129
|
+
const heightOutOfCanvas = params.maxHeight - this._canvasImage.height;
|
|
12130
|
+
const widthOutOfCanvas = params.maxWidth - this._canvasImage.width;
|
|
12131
|
+
if (heightOutOfCanvas <= this.EPSILON || widthOutOfCanvas <= this.EPSILON) {
|
|
12132
|
+
if (widthOutOfCanvas <= this.EPSILON && widthOutOfCanvas < heightOutOfCanvas / this._ratio) {
|
|
12133
|
+
this._ref.height(params.maxWidth * this._ratio);
|
|
12134
|
+
this._ref.width(params.maxWidth);
|
|
12135
|
+
}
|
|
12136
|
+
else {
|
|
12137
|
+
this._ref.width(params.maxHeight / this._ratio);
|
|
12138
|
+
this._ref.height(params.maxHeight);
|
|
12139
|
+
}
|
|
12140
|
+
}
|
|
12141
|
+
}
|
|
12119
12142
|
};
|
|
12120
12143
|
this._canvasImage.src = params.src;
|
|
12121
12144
|
this._ref.on("transform", (e) => {
|
|
@@ -13229,6 +13252,8 @@
|
|
|
13229
13252
|
src,
|
|
13230
13253
|
width,
|
|
13231
13254
|
height,
|
|
13255
|
+
maxWidth: this._konvaStage.width() - position.x,
|
|
13256
|
+
maxHeight: this._konvaStage.height() - position.y,
|
|
13232
13257
|
id,
|
|
13233
13258
|
});
|
|
13234
13259
|
this.addObject(konvaImage);
|