@syncfusion/ej2-image-editor 22.2.11 → 23.1.38
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/CHANGELOG.md +19 -0
- package/dist/ej2-image-editor.umd.min.js +3 -3
- package/dist/ej2-image-editor.umd.min.js.map +1 -1
- package/dist/es6/ej2-image-editor.es2015.js +4446 -678
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +4409 -632
- package/dist/es6/ej2-image-editor.es5.js.map +1 -1
- package/dist/global/ej2-image-editor.min.js +3 -3
- package/dist/global/ej2-image-editor.min.js.map +1 -1
- package/dist/global/index.d.ts +2 -2
- package/package.json +12 -12
- package/src/image-editor/action/crop.js +47 -30
- package/src/image-editor/action/draw.d.ts +16 -0
- package/src/image-editor/action/draw.js +827 -81
- package/src/image-editor/action/export.d.ts +3 -0
- package/src/image-editor/action/export.js +84 -20
- package/src/image-editor/action/filter.d.ts +0 -1
- package/src/image-editor/action/filter.js +28 -41
- package/src/image-editor/action/freehand-draw.d.ts +1 -0
- package/src/image-editor/action/freehand-draw.js +92 -56
- package/src/image-editor/action/selection.d.ts +6 -0
- package/src/image-editor/action/selection.js +417 -68
- package/src/image-editor/action/shape.d.ts +8 -0
- package/src/image-editor/action/shape.js +303 -91
- package/src/image-editor/action/transform.d.ts +9 -0
- package/src/image-editor/action/transform.js +402 -52
- package/src/image-editor/action/undo-redo.d.ts +1 -0
- package/src/image-editor/action/undo-redo.js +138 -10
- package/src/image-editor/base/enum.d.ts +38 -1
- package/src/image-editor/base/enum.js +39 -0
- package/src/image-editor/base/image-editor-model.d.ts +16 -2
- package/src/image-editor/base/image-editor.d.ts +142 -7
- package/src/image-editor/base/image-editor.js +719 -70
- package/src/image-editor/base/interface.d.ts +233 -2
- package/src/image-editor/renderer/toolbar.d.ts +25 -0
- package/src/image-editor/renderer/toolbar.js +1274 -72
- package/styles/bootstrap-dark.css +73 -1
- package/styles/bootstrap.css +73 -1
- package/styles/bootstrap4.css +73 -1
- package/styles/bootstrap5-dark.css +73 -1
- package/styles/bootstrap5.css +73 -1
- package/styles/fabric-dark.css +73 -1
- package/styles/fabric.css +73 -1
- package/styles/fluent-dark.css +73 -1
- package/styles/fluent.css +73 -1
- package/styles/highcontrast-light.css +75 -3
- package/styles/highcontrast.css +74 -7
- package/styles/image-editor/_bootstrap-dark-definition.scss +1 -0
- package/styles/image-editor/_bootstrap-definition.scss +1 -0
- package/styles/image-editor/_bootstrap4-definition.scss +1 -0
- package/styles/image-editor/_bootstrap5-definition.scss +1 -0
- package/styles/image-editor/_fabric-dark-definition.scss +1 -0
- package/styles/image-editor/_fabric-definition.scss +1 -0
- package/styles/image-editor/_fluent-definition.scss +1 -0
- package/styles/image-editor/_fusionnew-definition.scss +1 -0
- package/styles/image-editor/_highcontrast-definition.scss +2 -1
- package/styles/image-editor/_highcontrast-light-definition.scss +2 -1
- package/styles/image-editor/_layout.scss +98 -0
- package/styles/image-editor/_material-dark-definition.scss +1 -0
- package/styles/image-editor/_material-definition.scss +1 -0
- package/styles/image-editor/_material3-definition.scss +2 -1
- package/styles/image-editor/_tailwind-definition.scss +1 -0
- package/styles/image-editor/_theme.scss +4 -2
- package/styles/image-editor/bootstrap-dark.css +73 -1
- package/styles/image-editor/bootstrap-dark.scss +1 -1
- package/styles/image-editor/bootstrap.css +73 -1
- package/styles/image-editor/bootstrap.scss +1 -1
- package/styles/image-editor/bootstrap4.css +73 -1
- package/styles/image-editor/bootstrap4.scss +1 -1
- package/styles/image-editor/bootstrap5-dark.css +73 -1
- package/styles/image-editor/bootstrap5-dark.scss +1 -1
- package/styles/image-editor/bootstrap5.css +73 -1
- package/styles/image-editor/bootstrap5.scss +1 -1
- package/styles/image-editor/fabric-dark.css +73 -1
- package/styles/image-editor/fabric-dark.scss +1 -1
- package/styles/image-editor/fabric.css +73 -1
- package/styles/image-editor/fabric.scss +1 -1
- package/styles/image-editor/fluent-dark.css +73 -1
- package/styles/image-editor/fluent-dark.scss +1 -1
- package/styles/image-editor/fluent.css +73 -1
- package/styles/image-editor/fluent.scss +1 -1
- package/styles/image-editor/highcontrast-light.css +75 -3
- package/styles/image-editor/highcontrast-light.scss +1 -1
- package/styles/image-editor/highcontrast.css +74 -7
- package/styles/image-editor/highcontrast.scss +1 -1
- package/styles/image-editor/icons/_bootstrap-dark.scss +1 -0
- package/styles/image-editor/icons/_bootstrap.scss +1 -0
- package/styles/image-editor/icons/_bootstrap4.scss +1 -0
- package/styles/image-editor/icons/_bootstrap5.scss +1 -0
- package/styles/image-editor/icons/_fabric-dark.scss +1 -0
- package/styles/image-editor/icons/_fabric.scss +1 -0
- package/styles/image-editor/icons/_fluent.scss +1 -0
- package/styles/image-editor/icons/_fusionnew.scss +1 -0
- package/styles/image-editor/icons/_highcontrast-light.scss +1 -0
- package/styles/image-editor/icons/_highcontrast.scss +1 -0
- package/styles/image-editor/icons/_material-dark.scss +1 -0
- package/styles/image-editor/icons/_material.scss +1 -0
- package/styles/image-editor/icons/_material3.scss +1 -0
- package/styles/image-editor/icons/_tailwind.scss +1 -0
- package/styles/image-editor/material-dark.css +73 -2
- package/styles/image-editor/material-dark.scss +1 -1
- package/styles/image-editor/material.css +73 -2
- package/styles/image-editor/material.scss +1 -1
- package/styles/image-editor/material3-dark.css +78 -4
- package/styles/image-editor/material3-dark.scss +1 -1
- package/styles/image-editor/material3.css +78 -4
- package/styles/image-editor/material3.scss +1 -1
- package/styles/image-editor/tailwind-dark.css +73 -2
- package/styles/image-editor/tailwind-dark.scss +1 -1
- package/styles/image-editor/tailwind.css +73 -2
- package/styles/image-editor/tailwind.scss +1 -1
- package/styles/material-dark.css +73 -2
- package/styles/material.css +73 -2
- package/styles/material3-dark.css +78 -4
- package/styles/material3-dark.scss +1 -1
- package/styles/material3.css +78 -4
- package/styles/material3.scss +1 -1
- package/styles/tailwind-dark.css +73 -2
- package/styles/tailwind.css +73 -2
|
@@ -10,6 +10,8 @@ var Transform = /** @class */ (function () {
|
|
|
10
10
|
this.prevZoomValue = 1;
|
|
11
11
|
this.cropDimension = { width: 0, height: 0 };
|
|
12
12
|
this.isPreventSelect = false;
|
|
13
|
+
this.preventDownScale = false;
|
|
14
|
+
this.resizedImgAngle = null;
|
|
13
15
|
this.parent = parent;
|
|
14
16
|
this.addEventListener();
|
|
15
17
|
}
|
|
@@ -40,7 +42,7 @@ var Transform = /** @class */ (function () {
|
|
|
40
42
|
this.setDestPointsForFlipState();
|
|
41
43
|
break;
|
|
42
44
|
case 'zoomAction':
|
|
43
|
-
this.zoomAction(args.value['zoomFactor'], args.value['zoomPoint']);
|
|
45
|
+
this.zoomAction(args.value['zoomFactor'], args.value['zoomPoint'], args.value['isResize']);
|
|
44
46
|
break;
|
|
45
47
|
case 'disableZoomOutBtn':
|
|
46
48
|
this.disableZoomOutBtn(args.value['isZoomOut']);
|
|
@@ -94,7 +96,7 @@ var Transform = /** @class */ (function () {
|
|
|
94
96
|
this.update();
|
|
95
97
|
break;
|
|
96
98
|
case 'calcMaxDimension':
|
|
97
|
-
this.calcMaxDimension(args.value['width'], args.value['height'], args.value['obj']);
|
|
99
|
+
this.calcMaxDimension(args.value['width'], args.value['height'], args.value['obj'], args.value['isImgShape']);
|
|
98
100
|
break;
|
|
99
101
|
case 'updatePanPoints':
|
|
100
102
|
this.updatePanPoints(args.value['panRegion'], args.value['obj']);
|
|
@@ -150,6 +152,21 @@ var Transform = /** @class */ (function () {
|
|
|
150
152
|
case 'setPreventSelect':
|
|
151
153
|
this.isPreventSelect = args.value['bool'];
|
|
152
154
|
break;
|
|
155
|
+
case 'resizeImage':
|
|
156
|
+
this.resizeImage(args.value['width'], args.value['height']);
|
|
157
|
+
break;
|
|
158
|
+
case 'resizeCrop':
|
|
159
|
+
this.resizeCrop(args.value['width'], args.value['height']);
|
|
160
|
+
break;
|
|
161
|
+
case 'setPreventDownScale':
|
|
162
|
+
this.preventDownScale = args.value['bool'];
|
|
163
|
+
break;
|
|
164
|
+
case 'updateResize':
|
|
165
|
+
this.updateResize();
|
|
166
|
+
break;
|
|
167
|
+
case 'resize':
|
|
168
|
+
this.resize(args.value['width'], args.value['height'], args.value['isAspectRatio']);
|
|
169
|
+
break;
|
|
153
170
|
case 'reset':
|
|
154
171
|
this.reset();
|
|
155
172
|
break;
|
|
@@ -174,9 +191,10 @@ var Transform = /** @class */ (function () {
|
|
|
174
191
|
this.currDestPoint = null;
|
|
175
192
|
this.isReverseRotate = false;
|
|
176
193
|
this.flipColl = [];
|
|
194
|
+
this.resizedImgAngle = null;
|
|
177
195
|
this.transCurrObj = null;
|
|
178
196
|
this.prevZoomValue = 1;
|
|
179
|
-
this.isPreventSelect = false;
|
|
197
|
+
this.isPreventSelect = this.preventDownScale = false;
|
|
180
198
|
};
|
|
181
199
|
Transform.prototype.rotateImage = function (degree) {
|
|
182
200
|
var _this = this;
|
|
@@ -311,8 +329,7 @@ var Transform = /** @class */ (function () {
|
|
|
311
329
|
this.lowerContext.rotate(Math.PI / 180 * degree);
|
|
312
330
|
this.lowerContext.translate(-parent.lowerCanvas.width / 2, -parent.lowerCanvas.height / 2);
|
|
313
331
|
var temp = this.lowerContext.filter;
|
|
314
|
-
|
|
315
|
-
this.lowerContext.drawImage(this.parent.baseImg, this.parent.img.srcLeft, this.parent.img.srcTop, this.parent.img.srcWidth, this.parent.img.srcHeight, this.parent.img.destLeft, this.parent.img.destTop, this.parent.img.destWidth, this.parent.img.destHeight);
|
|
332
|
+
parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
|
|
316
333
|
this.lowerContext.filter = temp;
|
|
317
334
|
this.lowerContext.translate(parent.lowerCanvas.width / 2, parent.lowerCanvas.height / 2);
|
|
318
335
|
this.lowerContext.rotate(Math.PI / 180 * -degree);
|
|
@@ -337,8 +354,8 @@ var Transform = /** @class */ (function () {
|
|
|
337
354
|
}
|
|
338
355
|
parent.img.srcLeft = 0;
|
|
339
356
|
parent.img.srcTop = 0;
|
|
340
|
-
parent.img.srcWidth = parent.
|
|
341
|
-
parent.img.srcHeight = parent.
|
|
357
|
+
parent.img.srcWidth = parent.baseImgCanvas.width;
|
|
358
|
+
parent.img.srcHeight = parent.baseImgCanvas.height;
|
|
342
359
|
parent.img.destLeft = this.currDestPoint.startX;
|
|
343
360
|
parent.img.destTop = this.currDestPoint.startY;
|
|
344
361
|
parent.img.destWidth = this.currDestPoint.width;
|
|
@@ -368,7 +385,7 @@ var Transform = /** @class */ (function () {
|
|
|
368
385
|
var _this = this;
|
|
369
386
|
var parent = this.parent;
|
|
370
387
|
var transitionArgs = { direction: direction, cancel: false,
|
|
371
|
-
previousDirection: parent.toPascalCase(parent.transform.currFlipState) };
|
|
388
|
+
previousDirection: parent.toPascalCase(parent.transform.currFlipState || direction) };
|
|
372
389
|
if (!this.isPreventSelect && isBlazor() && parent.events && parent.events.flipping.hasDelegate === true) {
|
|
373
390
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
374
391
|
parent.dotNetRef.invokeMethodAsync('FlipEventAsync', 'OnFlip', transitionArgs).then(function (args) {
|
|
@@ -441,8 +458,7 @@ var Transform = /** @class */ (function () {
|
|
|
441
458
|
parent.img.destTop += parent.panPoint.totalPannedInternalPoint.y;
|
|
442
459
|
}
|
|
443
460
|
var temp = this.lowerContext.filter;
|
|
444
|
-
parent.notify('
|
|
445
|
-
this.lowerContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
|
|
461
|
+
parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
|
|
446
462
|
this.lowerContext.filter = temp;
|
|
447
463
|
parent.notify('draw', { prop: 'setImageEdited', onPropertyChange: false });
|
|
448
464
|
this.updateFlipState(direction.toLowerCase());
|
|
@@ -594,13 +610,13 @@ var Transform = /** @class */ (function () {
|
|
|
594
610
|
}
|
|
595
611
|
}
|
|
596
612
|
};
|
|
597
|
-
Transform.prototype.zoomAction = function (zoomFactor, zoomPoint) {
|
|
613
|
+
Transform.prototype.zoomAction = function (zoomFactor, zoomPoint, isResize) {
|
|
598
614
|
var _this = this;
|
|
599
615
|
var parent = this.parent;
|
|
600
616
|
if (!parent.disabled && parent.isImageLoaded) {
|
|
601
|
-
if (parent.zoomSettings.zoomFactor >= parent.zoomSettings.maxZoomFactor && zoomFactor > 0 ||
|
|
617
|
+
if (isNullOrUndefined(isResize) && (parent.zoomSettings.zoomFactor >= parent.zoomSettings.maxZoomFactor && zoomFactor > 0 ||
|
|
602
618
|
(parent.zoomSettings.zoomFactor > parent.zoomSettings.minZoomFactor && zoomFactor < 0 && this.disableZoomOutBtn(true)) ||
|
|
603
|
-
(parent.zoomSettings.zoomFactor <= parent.zoomSettings.minZoomFactor && zoomFactor < 0)) {
|
|
619
|
+
(parent.zoomSettings.zoomFactor <= parent.zoomSettings.minZoomFactor && zoomFactor < 0))) {
|
|
604
620
|
if (!isBlazor()) {
|
|
605
621
|
parent.notify('toolbar', { prop: 'zoom-up-handler', onPropertyChange: false });
|
|
606
622
|
}
|
|
@@ -609,7 +625,7 @@ var Transform = /** @class */ (function () {
|
|
|
609
625
|
parent.notify('draw', { prop: 'setImageEdited', onPropertyChange: false });
|
|
610
626
|
var tempZoomFactor = zoomFactor;
|
|
611
627
|
zoomFactor = tempZoomFactor > 0 ? 0.1 : -0.1;
|
|
612
|
-
for (var i = 0; i < Math.abs(tempZoomFactor / 0.1); i++) {
|
|
628
|
+
for (var i = 0; i < Math.round(Math.abs(tempZoomFactor / 0.1)); i++) {
|
|
613
629
|
if (this.prevZoomValue === 1) {
|
|
614
630
|
this.prevZoomValue += zoomFactor > 0 ? zoomFactor * 10 : (zoomFactor * 10) / 10;
|
|
615
631
|
}
|
|
@@ -681,7 +697,7 @@ var Transform = /** @class */ (function () {
|
|
|
681
697
|
if (!isBlazor()) {
|
|
682
698
|
parent.notify('toolbar', { prop: 'close-contextual-toolbar', onPropertyChange: false });
|
|
683
699
|
}
|
|
684
|
-
else if (parent.element.querySelector('.e-contextual-toolbar-wrapper') && !parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.contains('e-hidden')) {
|
|
700
|
+
else if (parent.currentToolbar !== 'resize-toolbar' && parent.element.querySelector('.e-contextual-toolbar-wrapper') && !parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.contains('e-hidden')) {
|
|
685
701
|
parent.updateToolbar(parent.element, 'closeContextualToolbar');
|
|
686
702
|
}
|
|
687
703
|
parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
|
|
@@ -697,7 +713,10 @@ var Transform = /** @class */ (function () {
|
|
|
697
713
|
parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
|
|
698
714
|
value: { x: null, y: null, isMouseDown: null } });
|
|
699
715
|
parent.panPoint.currentPannedPoint = { x: 0, y: 0 };
|
|
716
|
+
var temp = parent.allowDownScale;
|
|
717
|
+
parent.allowDownScale = false;
|
|
700
718
|
this.rotatePan(true, true);
|
|
719
|
+
parent.allowDownScale = temp;
|
|
701
720
|
}
|
|
702
721
|
else if (parent.transform.currFlipState !== '') {
|
|
703
722
|
parent.panPoint.totalPannedPoint = { x: 0, y: 0 };
|
|
@@ -925,8 +944,7 @@ var Transform = /** @class */ (function () {
|
|
|
925
944
|
parent.notify('draw', { prop: 'currTransState', onPropertyChange: false,
|
|
926
945
|
value: { type: 'initial', isPreventDestination: null, context: null, isPreventCircleCrop: null } });
|
|
927
946
|
var temp = this.lowerContext.filter;
|
|
928
|
-
parent.notify('
|
|
929
|
-
this.lowerContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
|
|
947
|
+
parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
|
|
930
948
|
this.lowerContext.filter = temp;
|
|
931
949
|
parent.notify('draw', { prop: 'currTransState', onPropertyChange: false,
|
|
932
950
|
value: { type: 'reverse', isPreventDestination: true, context: null, isPreventCircleCrop: null } });
|
|
@@ -968,8 +986,7 @@ var Transform = /** @class */ (function () {
|
|
|
968
986
|
parent.notify('draw', { prop: 'setRotateZoom', onPropertyChange: false, value: { isRotateZoom: true } });
|
|
969
987
|
parent.notify('draw', { prop: 'setDestPoints', onPropertyChange: false });
|
|
970
988
|
var temp = this.lowerContext.filter;
|
|
971
|
-
parent.notify('
|
|
972
|
-
this.lowerContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
|
|
989
|
+
parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
|
|
973
990
|
this.lowerContext.filter = temp;
|
|
974
991
|
parent.notify('draw', { prop: 'setRotateZoom', onPropertyChange: false, value: { isRotateZoom: false } });
|
|
975
992
|
parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
|
|
@@ -1212,8 +1229,7 @@ var Transform = /** @class */ (function () {
|
|
|
1212
1229
|
parent.img.destWidth = destPoints.width;
|
|
1213
1230
|
parent.img.destHeight = destPoints.height;
|
|
1214
1231
|
this.setDestPointsForFlipState();
|
|
1215
|
-
parent.notify('
|
|
1216
|
-
this.lowerContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
|
|
1232
|
+
parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
|
|
1217
1233
|
if ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
|
|
1218
1234
|
parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
|
|
1219
1235
|
value: { context: this.lowerContext, isSave: null, isFlip: true } });
|
|
@@ -1351,8 +1367,7 @@ var Transform = /** @class */ (function () {
|
|
|
1351
1367
|
parent.panPoint.totalPannedInternalPoint.y = parent.img.destTop - initialDestTop;
|
|
1352
1368
|
}
|
|
1353
1369
|
var temp = this.lowerContext.filter;
|
|
1354
|
-
parent.notify('
|
|
1355
|
-
this.lowerContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
|
|
1370
|
+
parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
|
|
1356
1371
|
parent.notify('draw', { prop: 'setRotateZoom', onPropertyChange: false, value: { isRotateZoom: false } });
|
|
1357
1372
|
parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
|
|
1358
1373
|
value: { type: 'reverse', isPreventDestination: true, isRotatePan: true } });
|
|
@@ -1561,9 +1576,15 @@ var Transform = /** @class */ (function () {
|
|
|
1561
1576
|
Transform.prototype.update = function () {
|
|
1562
1577
|
var parent = this.parent;
|
|
1563
1578
|
var toolbarHeight = 0;
|
|
1579
|
+
var isFrameToolbar = false;
|
|
1564
1580
|
var isActiveObj = false;
|
|
1565
1581
|
var freehandObj = { bool: false };
|
|
1566
1582
|
if (parent.isImageLoaded) {
|
|
1583
|
+
var frameObj = { bool: null };
|
|
1584
|
+
parent.notify('toolbar', { prop: 'getFrameToolbar', onPropertyChange: false, value: { obj: frameObj } });
|
|
1585
|
+
if (frameObj['bool'] || (isBlazor() && parent.currentToolbar == 'frame-toolbar')) {
|
|
1586
|
+
isFrameToolbar = true;
|
|
1587
|
+
}
|
|
1567
1588
|
if ((parent.element.querySelector('#' + parent.element.id + '_contextualToolbar') &&
|
|
1568
1589
|
!parent.element.querySelector('#' + parent.element.id + '_contextualToolbar').parentElement.classList.contains('e-hide')) ||
|
|
1569
1590
|
(parent.element.querySelector('#' + parent.element.id + '_headWrapper')
|
|
@@ -1666,8 +1687,7 @@ var Transform = /** @class */ (function () {
|
|
|
1666
1687
|
}
|
|
1667
1688
|
}
|
|
1668
1689
|
var obj = { width: 0, height: 0 };
|
|
1669
|
-
parent.
|
|
1670
|
-
value: { width: parent.img.srcWidth, height: parent.img.srcHeight, obj: obj } });
|
|
1690
|
+
this.calcMaxDimension(parent.img.srcWidth, parent.img.srcHeight, obj);
|
|
1671
1691
|
var maxDimension = obj;
|
|
1672
1692
|
if (parent.transform.defaultZoomFactor > 0) {
|
|
1673
1693
|
maxDimension.width += (maxDimension.width * parent.transform.defaultZoomFactor);
|
|
@@ -1687,8 +1707,7 @@ var Transform = /** @class */ (function () {
|
|
|
1687
1707
|
parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
|
|
1688
1708
|
value: { type: 'initial', isPreventDestination: null, isRotatePan: null } });
|
|
1689
1709
|
var temp = this.lowerContext.filter;
|
|
1690
|
-
parent.notify('
|
|
1691
|
-
this.lowerContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
|
|
1710
|
+
parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
|
|
1692
1711
|
this.lowerContext.filter = temp;
|
|
1693
1712
|
parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
|
|
1694
1713
|
value: { type: 'reverse', isPreventDestination: null, isRotatePan: null } });
|
|
@@ -1716,12 +1735,15 @@ var Transform = /** @class */ (function () {
|
|
|
1716
1735
|
parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
|
|
1717
1736
|
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
1718
1737
|
if (isActiveObj) {
|
|
1719
|
-
|
|
1738
|
+
var activeObj = extend({}, parent.objColl[parent.objColl.length - 1], null, true);
|
|
1720
1739
|
parent.objColl.pop();
|
|
1721
|
-
if (
|
|
1722
|
-
|
|
1740
|
+
if (activeObj.activePoint.width !== 0 && activeObj.activePoint.height !== 0) {
|
|
1741
|
+
this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
1742
|
+
parent.notify('draw', { prop: 'render-image', value: { isMouseWheel: true } });
|
|
1743
|
+
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: activeObj } });
|
|
1723
1744
|
if (parent.activeObj.shape === 'rectangle' || parent.activeObj.shape === 'ellipse' || parent.activeObj.shape === 'text' ||
|
|
1724
|
-
parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow' || parent.activeObj.shape === 'path'
|
|
1745
|
+
parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow' || parent.activeObj.shape === 'path' ||
|
|
1746
|
+
parent.activeObj.shape === 'image') {
|
|
1725
1747
|
if (!isBlazor()) {
|
|
1726
1748
|
parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
|
|
1727
1749
|
}
|
|
@@ -1739,14 +1761,33 @@ var Transform = /** @class */ (function () {
|
|
|
1739
1761
|
parent.updateToolbar(parent.element, 'quickAccessToolbar', 'pen');
|
|
1740
1762
|
}
|
|
1741
1763
|
}
|
|
1764
|
+
if (isFrameToolbar) {
|
|
1765
|
+
if (isBlazor()) {
|
|
1766
|
+
parent.updateToolbar(parent.element, 'frame');
|
|
1767
|
+
}
|
|
1768
|
+
else {
|
|
1769
|
+
parent.notify('toolbar', { prop: 'callFrameToolbar', onPropertyChange: false });
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
else if (parent.isResize) {
|
|
1773
|
+
parent.aspectWidth = Math.ceil(parent.img.destWidth);
|
|
1774
|
+
parent.aspectHeight = Math.ceil(parent.img.destHeight);
|
|
1775
|
+
if (isBlazor()) {
|
|
1776
|
+
parent.updateToolbar(parent.element, 'resize');
|
|
1777
|
+
}
|
|
1778
|
+
else {
|
|
1779
|
+
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'resize',
|
|
1780
|
+
isApplyBtn: false, isCropping: false } });
|
|
1781
|
+
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'resize',
|
|
1782
|
+
isApplyBtn: false, isCropping: false } });
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1742
1785
|
if ((parent.transform.degree !== 0 || parent.transform.currFlipState !== '') && parent.transform.defaultZoomFactor > 0) {
|
|
1743
1786
|
var totalPannedPoint = extend({}, parent.panPoint.totalPannedPoint, null, true);
|
|
1744
1787
|
var totalPannedInternalPoint = extend({}, parent.panPoint.totalPannedInternalPoint, null, true);
|
|
1745
1788
|
var totalPannedClientPoint = extend({}, parent.panPoint.totalPannedClientPoint, null, true);
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
1749
|
-
value: { zoomFactor: -.1, zoomPoint: null } });
|
|
1789
|
+
this.zoomAction(.1);
|
|
1790
|
+
this.zoomAction(-.1);
|
|
1750
1791
|
if (parent.transform.degree === 0) {
|
|
1751
1792
|
parent.img.destLeft += totalPannedPoint.x;
|
|
1752
1793
|
parent.img.destTop += totalPannedPoint.y;
|
|
@@ -1758,8 +1799,7 @@ var Transform = /** @class */ (function () {
|
|
|
1758
1799
|
parent.panPoint.totalPannedClientPoint = totalPannedClientPoint;
|
|
1759
1800
|
parent.panPoint.currentPannedPoint = { x: 0, y: 0 };
|
|
1760
1801
|
parent.isCropTab = true;
|
|
1761
|
-
|
|
1762
|
-
value: { isCropSelection: null, isDefaultZoom: null } });
|
|
1802
|
+
this.rotatePan();
|
|
1763
1803
|
parent.isCropTab = false;
|
|
1764
1804
|
}
|
|
1765
1805
|
}
|
|
@@ -1775,7 +1815,7 @@ var Transform = /** @class */ (function () {
|
|
|
1775
1815
|
}
|
|
1776
1816
|
}
|
|
1777
1817
|
};
|
|
1778
|
-
Transform.prototype.calcMaxDimension = function (width, height, obj) {
|
|
1818
|
+
Transform.prototype.calcMaxDimension = function (width, height, obj, isImgShape) {
|
|
1779
1819
|
var object = { toolbarHeight: 0 };
|
|
1780
1820
|
if (!isBlazor()) {
|
|
1781
1821
|
this.parent.notify('toolbar', { prop: 'getToolbarHeight', value: { obj: object } });
|
|
@@ -1783,14 +1823,18 @@ var Transform = /** @class */ (function () {
|
|
|
1783
1823
|
else {
|
|
1784
1824
|
object['toolbarHeight'] = this.parent.toolbarHeight;
|
|
1785
1825
|
}
|
|
1786
|
-
var canvasMaxWidth = this.parent.element.clientWidth
|
|
1787
|
-
|
|
1826
|
+
var canvasMaxWidth = isImgShape ? this.parent.element.clientWidth / 3 :
|
|
1827
|
+
this.parent.element.clientWidth;
|
|
1828
|
+
var canvasMaxHeight = isImgShape ? (this.parent.element.clientHeight - object['toolbarHeight']) / 3 :
|
|
1829
|
+
this.parent.element.clientHeight - object['toolbarHeight'];
|
|
1788
1830
|
canvasMaxHeight = Browser.isDevice ? canvasMaxHeight - object['toolbarHeight'] : canvasMaxHeight;
|
|
1789
|
-
if (
|
|
1790
|
-
canvasMaxWidth
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
canvasMaxHeight
|
|
1831
|
+
if (isNullOrUndefined(isImgShape)) {
|
|
1832
|
+
if (canvasMaxWidth > 30) {
|
|
1833
|
+
canvasMaxWidth -= 30;
|
|
1834
|
+
}
|
|
1835
|
+
if (canvasMaxHeight > 30) {
|
|
1836
|
+
canvasMaxHeight -= 30;
|
|
1837
|
+
}
|
|
1794
1838
|
}
|
|
1795
1839
|
var widthScale = canvasMaxWidth / width;
|
|
1796
1840
|
var heightScale = canvasMaxHeight / height;
|
|
@@ -1804,13 +1848,15 @@ var Transform = /** @class */ (function () {
|
|
|
1804
1848
|
cssMaxWidth = width * heightScale;
|
|
1805
1849
|
cssMaxHeight = height * heightScale;
|
|
1806
1850
|
}
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1851
|
+
if (isNullOrUndefined(isImgShape)) {
|
|
1852
|
+
var cropObj = { bool: null };
|
|
1853
|
+
this.parent.notify('crop', { prop: 'getPreventScaling', onPropertyChange: false,
|
|
1854
|
+
value: { obj: cropObj } });
|
|
1855
|
+
if (cropObj['bool'] && this.parent.cropObj.activeObj.activePoint &&
|
|
1856
|
+
this.parent.cropObj.activeObj.activePoint.width !== 0 && this.parent.cropObj.activeObj.activePoint.height !== 0) {
|
|
1857
|
+
cssMaxWidth = this.parent.cropObj.activeObj.activePoint.width;
|
|
1858
|
+
cssMaxHeight = this.parent.cropObj.activeObj.activePoint.height;
|
|
1859
|
+
}
|
|
1814
1860
|
}
|
|
1815
1861
|
if (obj) {
|
|
1816
1862
|
obj['width'] = cssMaxWidth;
|
|
@@ -1866,6 +1912,310 @@ var Transform = /** @class */ (function () {
|
|
|
1866
1912
|
}
|
|
1867
1913
|
return { x: parent.img.destLeft - tempDestLeft, y: parent.img.destTop - tempDestTop };
|
|
1868
1914
|
};
|
|
1915
|
+
Transform.prototype.resizeImage = function (width, height) {
|
|
1916
|
+
var parent = this.parent;
|
|
1917
|
+
var temp = true;
|
|
1918
|
+
var temp1 = true;
|
|
1919
|
+
parent.allowDownScale = false;
|
|
1920
|
+
parent.img.srcLeft = 0;
|
|
1921
|
+
parent.img.srcTop = 0;
|
|
1922
|
+
parent.isAspectRatio = true;
|
|
1923
|
+
var minimum = [];
|
|
1924
|
+
parent.img.srcWidth = parent.baseImg.width;
|
|
1925
|
+
parent.img.srcHeight = parent.baseImg.height;
|
|
1926
|
+
if (parent.resizeSrc && parent.resizeSrc.width != 0 && parent.resizeSrc.height != 0) {
|
|
1927
|
+
parent.img.srcLeft = parent.resizeSrc.startX;
|
|
1928
|
+
parent.img.srcTop = parent.resizeSrc.startY;
|
|
1929
|
+
parent.img.srcWidth = parent.resizeSrc.width;
|
|
1930
|
+
parent.img.srcHeight = parent.resizeSrc.height;
|
|
1931
|
+
}
|
|
1932
|
+
while ((width < parent.img.destWidth || height < parent.img.destHeight) && temp1) {
|
|
1933
|
+
this.zoomAction(-.1, null, true);
|
|
1934
|
+
if (width > parent.img.destWidth || height > parent.img.destHeight) {
|
|
1935
|
+
while (width > parent.img.destWidth || height > parent.img.destHeight) {
|
|
1936
|
+
this.zoomAction(0.0125, null, true);
|
|
1937
|
+
temp1 = false;
|
|
1938
|
+
minimum.push(parent.img.destWidth);
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
while ((width > parent.img.destWidth || height > parent.img.destHeight) && temp1 && temp) {
|
|
1943
|
+
this.zoomAction(.1, null, true);
|
|
1944
|
+
if (width < parent.img.destWidth || height < parent.img.destHeight) {
|
|
1945
|
+
while (width < parent.img.destWidth) {
|
|
1946
|
+
this.zoomAction(-.0125, null, true);
|
|
1947
|
+
temp = false;
|
|
1948
|
+
minimum.push(parent.img.destWidth);
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
var nearestNumber = minimum[0];
|
|
1953
|
+
var smallestDifference = Math.abs(parent.img.destWidth - nearestNumber);
|
|
1954
|
+
for (var _i = 0, minimum_1 = minimum; _i < minimum_1.length; _i++) {
|
|
1955
|
+
var num = minimum_1[_i];
|
|
1956
|
+
var difference = Math.abs(width - num);
|
|
1957
|
+
if (difference < smallestDifference) {
|
|
1958
|
+
nearestNumber = num;
|
|
1959
|
+
smallestDifference = difference;
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
if (nearestNumber < width && temp) {
|
|
1963
|
+
this.zoomAction(-.0125, null, true);
|
|
1964
|
+
temp = false;
|
|
1965
|
+
}
|
|
1966
|
+
if (nearestNumber > width && !temp) {
|
|
1967
|
+
this.zoomAction(.0125, null, true);
|
|
1968
|
+
temp = false;
|
|
1969
|
+
}
|
|
1970
|
+
this.zoomAction(.0125, null, true);
|
|
1971
|
+
parent.allowDownScale = true;
|
|
1972
|
+
this.zoomAction(-.0125, null, true);
|
|
1973
|
+
var prevCropObj = extend({}, parent.cropObj, {}, true);
|
|
1974
|
+
var prevObj = extend({}, this.prevResizeCurrObj, {}, true);
|
|
1975
|
+
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false, value: { operation: 'resize',
|
|
1976
|
+
previousObj: prevObj, previousObjColl: prevObj.objColl, previousPointColl: prevObj.pointColl,
|
|
1977
|
+
previousSelPointColl: prevObj.selPointColl, previousCropObj: prevCropObj, previousText: null, currentText: null,
|
|
1978
|
+
previousFilter: null, isCircleCrop: parent.isCircleCrop } });
|
|
1979
|
+
parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
|
|
1980
|
+
};
|
|
1981
|
+
Transform.prototype.resizeCrop = function (width, height) {
|
|
1982
|
+
var parent = this.parent;
|
|
1983
|
+
var temp = true;
|
|
1984
|
+
var obj1 = { prevObj: parent.prevObj };
|
|
1985
|
+
parent.cropObj = extend({}, parent.prevCropObj, {}, true);
|
|
1986
|
+
parent.allowDownScale = false;
|
|
1987
|
+
parent.notify('toolbar', { prop: 'getPrevObj', onPropertyChange: false, value: { obj: obj1 } });
|
|
1988
|
+
var activeObj = extend({}, obj1['prevObj']['activeObj'], {}, true);
|
|
1989
|
+
obj1['prevObj']['activeObj'] = extend({}, parent.activeObj, {}, true);
|
|
1990
|
+
parent.notify('draw', { prop: 'setCurrentObj', onPropertyChange: false, value: { obj: obj1['prevObj'] } });
|
|
1991
|
+
parent.objColl = extend([], obj1['prevObj']['objColl'], [], true);
|
|
1992
|
+
parent.pointColl = extend([], obj1['prevObj']['pointColl'], [], true);
|
|
1993
|
+
parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
1994
|
+
parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
1995
|
+
parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false });
|
|
1996
|
+
var tempwidth = width;
|
|
1997
|
+
var tempheight = height;
|
|
1998
|
+
var tempZoom = false;
|
|
1999
|
+
if (height >= width && height <= Math.ceil(parent.img.destHeight)) {
|
|
2000
|
+
while ((height <= Math.ceil(parent.img.destHeight)) && temp) {
|
|
2001
|
+
this.zoomAction(-.1, null, true);
|
|
2002
|
+
if (width > parent.img.destWidth || height > parent.img.destHeight) {
|
|
2003
|
+
while (width > parent.img.destWidth || height > parent.img.destHeight) {
|
|
2004
|
+
this.zoomAction(.0125, null, true);
|
|
2005
|
+
temp = false;
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
else if (height <= width && width < parent.img.destWidth) {
|
|
2011
|
+
while ((width < parent.img.destWidth) && temp) {
|
|
2012
|
+
this.zoomAction(-.1, null, true);
|
|
2013
|
+
if (width > parent.img.destWidth || height > parent.img.destHeight) {
|
|
2014
|
+
while (width > parent.img.destWidth || height > parent.img.destHeight) {
|
|
2015
|
+
this.zoomAction(.0125, null, true);
|
|
2016
|
+
temp = false;
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
else if (height >= width && height >= parent.img.destHeight) {
|
|
2022
|
+
while ((height >= parent.img.destHeight) && temp) {
|
|
2023
|
+
this.zoomAction(.1, null, true);
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
else if (width >= height && width >= parent.img.destWidth) {
|
|
2027
|
+
while ((width >= parent.img.destWidth) && temp) {
|
|
2028
|
+
this.zoomAction(.1, null, true);
|
|
2029
|
+
}
|
|
2030
|
+
if (width < parent.img.destWidth && height < parent.img.destHeight) {
|
|
2031
|
+
while (width < parent.img.destWidth && height < parent.img.destHeight) {
|
|
2032
|
+
this.zoomAction(-.0125, null, true);
|
|
2033
|
+
temp = false;
|
|
2034
|
+
}
|
|
2035
|
+
this.zoomAction(.0125, null, true);
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
else if (height > parent.img.destHeight && width > parent.img.destWidth) {
|
|
2039
|
+
while ((height > parent.img.destHeight) && (width > parent.img.destWidth) && temp) {
|
|
2040
|
+
this.zoomAction(.1, null, true);
|
|
2041
|
+
}
|
|
2042
|
+
if (width < parent.img.destWidth && height < parent.img.destHeight) {
|
|
2043
|
+
while (width < parent.img.destWidth && height < parent.img.destHeight) {
|
|
2044
|
+
this.zoomAction(-.0125, null, true);
|
|
2045
|
+
temp = false;
|
|
2046
|
+
}
|
|
2047
|
+
this.zoomAction(.0125, null, true);
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
this.resizeImg(activeObj, width, height);
|
|
2051
|
+
width = tempwidth;
|
|
2052
|
+
height = tempheight;
|
|
2053
|
+
if ((height !== parent.img.destHeight || width !== parent.img.destWidth)) {
|
|
2054
|
+
while ((height > parent.img.destHeight || width > parent.img.destWidth)) {
|
|
2055
|
+
this.zoomAction(.0125, null, true);
|
|
2056
|
+
tempZoom = true;
|
|
2057
|
+
}
|
|
2058
|
+
if (tempZoom) {
|
|
2059
|
+
this.zoomAction(-.0125, null, true);
|
|
2060
|
+
tempZoom = false;
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
if ((height !== parent.img.destHeight || width !== parent.img.destWidth)) {
|
|
2064
|
+
while ((height < parent.img.destHeight || width < parent.img.destWidth)) {
|
|
2065
|
+
this.zoomAction(-.0125, null, true);
|
|
2066
|
+
tempZoom = true;
|
|
2067
|
+
}
|
|
2068
|
+
if (tempZoom) {
|
|
2069
|
+
this.zoomAction(-.0125, null, true);
|
|
2070
|
+
tempZoom = false;
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
obj1['prevObj']['activeObj'] = extend({}, activeObj, {}, true);
|
|
2074
|
+
this.zoomAction(.0125, null, true);
|
|
2075
|
+
parent.allowDownScale = this.preventDownScale ? false : true;
|
|
2076
|
+
parent.isCropTab = false;
|
|
2077
|
+
this.zoomAction(-.0125, null, true);
|
|
2078
|
+
parent.aspectWidth = width;
|
|
2079
|
+
parent.aspectHeight = height;
|
|
2080
|
+
};
|
|
2081
|
+
Transform.prototype.resizeImg = function (activeObj, width, height) {
|
|
2082
|
+
var parent = this.parent;
|
|
2083
|
+
var widthRatio = width / parent.img.destWidth;
|
|
2084
|
+
var heightRatio = height / parent.img.destHeight;
|
|
2085
|
+
if (activeObj.shape) {
|
|
2086
|
+
parent.currSelectionPoint = activeObj;
|
|
2087
|
+
}
|
|
2088
|
+
else if (parent.img.srcWidth === parent.baseImgCanvas.width && parent.img.srcHeight === parent.baseImgCanvas.height) {
|
|
2089
|
+
parent.currSelectionPoint = null;
|
|
2090
|
+
parent.select('custom');
|
|
2091
|
+
}
|
|
2092
|
+
if (isNullOrUndefined(parent.currSelectionPoint)) {
|
|
2093
|
+
parent.select('custom', parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
|
|
2094
|
+
}
|
|
2095
|
+
else {
|
|
2096
|
+
parent.select('custom');
|
|
2097
|
+
}
|
|
2098
|
+
width = parent.activeObj.activePoint.width * widthRatio;
|
|
2099
|
+
height = parent.activeObj.activePoint.height * heightRatio;
|
|
2100
|
+
var sx = (parent.activeObj.activePoint.startX + (parent.activeObj.activePoint.width / 2)) - (width / 2);
|
|
2101
|
+
var sy = (parent.activeObj.activePoint.startY + (parent.activeObj.activePoint.height / 2)) - (height / 2);
|
|
2102
|
+
parent.transform.defaultZoomFactor = 0;
|
|
2103
|
+
parent.notify('draw', { prop: 'setResizeSelect', value: { bool: true } });
|
|
2104
|
+
parent.select('custom', sx, sy, width, height);
|
|
2105
|
+
parent.notify('draw', { prop: 'setResizeSelect', value: { bool: false } });
|
|
2106
|
+
parent.isCropToolbar = true;
|
|
2107
|
+
parent.crop();
|
|
2108
|
+
parent.isCropToolbar = false;
|
|
2109
|
+
};
|
|
2110
|
+
Transform.prototype.updateResize = function () {
|
|
2111
|
+
var parent = this.parent;
|
|
2112
|
+
parent.prevCropObj = extend({}, parent.cropObj, {}, true);
|
|
2113
|
+
var currObject = { currObj: {} };
|
|
2114
|
+
parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: currObject } });
|
|
2115
|
+
parent.prevObj = currObject['currObj'];
|
|
2116
|
+
if (parent.currSelectionPoint && parent.prevCropObj.activeObj.shape) {
|
|
2117
|
+
parent.prevObj.activeObj = extend({}, parent.prevCropObj.activeObj, {}, true);
|
|
2118
|
+
}
|
|
2119
|
+
parent.prevObj.objColl = extend([], parent.objColl, [], true);
|
|
2120
|
+
parent.prevObj.pointColl = extend([], parent.pointColl, [], true);
|
|
2121
|
+
parent.prevObj.afterCropActions = extend([], parent.afterCropActions, [], true);
|
|
2122
|
+
var selPointCollObj = { selPointColl: null };
|
|
2123
|
+
parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
2124
|
+
value: { obj: selPointCollObj } });
|
|
2125
|
+
parent.prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
2126
|
+
parent.resizeSrc = { startX: parent.img.srcLeft, startY: parent.img.srcTop, width: parent.img.srcWidth,
|
|
2127
|
+
height: parent.img.srcHeight };
|
|
2128
|
+
};
|
|
2129
|
+
Transform.prototype.resize = function (width, height, isAspectRatio) {
|
|
2130
|
+
var _this = this;
|
|
2131
|
+
var parent = this.parent;
|
|
2132
|
+
parent.isResize = true;
|
|
2133
|
+
if (isNullOrUndefined(parent.prevCropObj) && isNullOrUndefined(parent.prevObj)) {
|
|
2134
|
+
parent.notify('transform', { prop: 'updateResize', value: { bool: false } });
|
|
2135
|
+
}
|
|
2136
|
+
var aspectIcon = parent.element.querySelector('#' + parent.element.id + '_aspectratio');
|
|
2137
|
+
var nonAspectIcon = parent.element.querySelector('#' + parent.element.id + '_nonaspectratio');
|
|
2138
|
+
if (!isNullOrUndefined(aspectIcon) && !isNullOrUndefined(nonAspectIcon)) {
|
|
2139
|
+
parent.notify('toolbar', { prop: 'initResizeToolbar' });
|
|
2140
|
+
if (Browser.isDevice) {
|
|
2141
|
+
parent.notify('toolbar', { prop: 'init-main-toolbar', value: { isApplyBtn: false, isDevice: true, isOkBtn: true, isResize: true } });
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
var resizeEventArgs = { cancel: false, previousWidth: Math.ceil(parent.img.destWidth), previousHeight: Math.ceil(parent.img.destHeight),
|
|
2145
|
+
width: Math.ceil(width), height: height && height !== 0 ? Math.ceil(height) : (parent.aspectHeight ? parent.aspectHeight : Math.ceil(parent.img.destHeight)),
|
|
2146
|
+
isAspectRatio: isAspectRatio ? isAspectRatio : false };
|
|
2147
|
+
if (!isBlazor()) {
|
|
2148
|
+
parent.trigger('resizing', resizeEventArgs);
|
|
2149
|
+
if (!resizeEventArgs.cancel) {
|
|
2150
|
+
this.resizeEventHandler(resizeEventArgs);
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
else if (isBlazor() && parent.events && parent.events.imageResizing.hasDelegate === true) {
|
|
2154
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2155
|
+
parent.dotNetRef.invokeMethodAsync('OnImageResizingAsync', resizeEventArgs).then(function (args) {
|
|
2156
|
+
if (!args.cancel) {
|
|
2157
|
+
_this.resizeEventHandler(args);
|
|
2158
|
+
}
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
else {
|
|
2162
|
+
this.resizeEventHandler(resizeEventArgs);
|
|
2163
|
+
}
|
|
2164
|
+
};
|
|
2165
|
+
Transform.prototype.resizeEventHandler = function (args) {
|
|
2166
|
+
var parent = this.parent;
|
|
2167
|
+
var isRotate;
|
|
2168
|
+
var aspectRatioHeight = parent.element.querySelector('#' + parent.element.id + '_resizeHeight');
|
|
2169
|
+
var heightElem = parent.element.querySelector(".e-ie-toolbar-e-resize-height-input .e-numerictextbox");
|
|
2170
|
+
if (args.isAspectRatio) {
|
|
2171
|
+
if (this.resizedImgAngle == null || this.resizedImgAngle !== parent.transform.degree) {
|
|
2172
|
+
this.resizedImgAngle = parent.transform.degree;
|
|
2173
|
+
isRotate = true;
|
|
2174
|
+
}
|
|
2175
|
+
if (isRotate) {
|
|
2176
|
+
parent.notify('transform', { prop: 'resizeImage', value: { width: args.width, height: 0 } });
|
|
2177
|
+
if (aspectRatioHeight) {
|
|
2178
|
+
getComponent(aspectRatioHeight, 'numerictextbox').value = Math.floor(parent.img.destHeight);
|
|
2179
|
+
aspectRatioHeight.value = Math.floor(parent.img.destHeight).toString() + ' px';
|
|
2180
|
+
parent.aspectHeight = Math.floor(parent.img.destHeight);
|
|
2181
|
+
}
|
|
2182
|
+
else if (heightElem) {
|
|
2183
|
+
heightElem.value = Math.floor(parent.img.destHeight).toString();
|
|
2184
|
+
parent.aspectHeight = Math.floor(parent.img.destHeight);
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
else {
|
|
2188
|
+
parent.notify('transform', { prop: 'resizeImage', value: { width: args.width, height: null } });
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
else {
|
|
2192
|
+
if (this.resizedImgAngle !== null && this.resizedImgAngle !== parent.transform.degree) {
|
|
2193
|
+
this.resizedImgAngle = parent.transform.degree;
|
|
2194
|
+
isRotate = true;
|
|
2195
|
+
}
|
|
2196
|
+
if (isRotate) {
|
|
2197
|
+
parent.notify('transform', { prop: 'setPreventDownScale', value: { bool: true } });
|
|
2198
|
+
parent.notify('transform', { prop: 'resizeCrop', value: { width: args.width, height: args.height } });
|
|
2199
|
+
parent.okBtn();
|
|
2200
|
+
parent.resizeSrc = { startX: parent.img.srcLeft, startY: parent.img.srcTop, width: parent.img.srcWidth,
|
|
2201
|
+
height: parent.img.srcHeight };
|
|
2202
|
+
if (isBlazor()) {
|
|
2203
|
+
parent.updateToolbar(parent.element, 'resize');
|
|
2204
|
+
}
|
|
2205
|
+
else {
|
|
2206
|
+
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'resize',
|
|
2207
|
+
isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
|
|
2208
|
+
parent.notify('transform', { prop: 'setPreventDownScale', value: { bool: false } });
|
|
2209
|
+
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'resize',
|
|
2210
|
+
isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
else {
|
|
2214
|
+
parent.notify('transform', { prop: 'resizeCrop', value: { width: args.width, height: args.height } });
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
this.resizedImgAngle = parent.transform.degree;
|
|
2218
|
+
};
|
|
1869
2219
|
return Transform;
|
|
1870
2220
|
}());
|
|
1871
2221
|
export { Transform };
|