@syncfusion/ej2-image-editor 21.2.6 → 22.1.34

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.
Files changed (105) hide show
  1. package/.eslintrc.json +1 -0
  2. package/CHANGELOG.md +6 -24
  3. package/dist/ej2-image-editor.umd.min.js +2 -2
  4. package/dist/ej2-image-editor.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-image-editor.es2015.js +19186 -12390
  6. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  7. package/dist/es6/ej2-image-editor.es5.js +19217 -12390
  8. package/dist/es6/ej2-image-editor.es5.js.map +1 -1
  9. package/dist/global/ej2-image-editor.min.js +2 -2
  10. package/dist/global/ej2-image-editor.min.js.map +1 -1
  11. package/dist/global/index.d.ts +1 -1
  12. package/package.json +11 -11
  13. package/src/image-editor/action/crop.d.ts +35 -0
  14. package/src/image-editor/action/crop.js +818 -0
  15. package/src/image-editor/action/draw.d.ts +122 -0
  16. package/src/image-editor/action/draw.js +3253 -0
  17. package/src/image-editor/action/export.d.ts +23 -0
  18. package/src/image-editor/action/export.js +364 -0
  19. package/src/image-editor/action/filter.d.ts +35 -0
  20. package/src/image-editor/action/filter.js +699 -0
  21. package/src/image-editor/action/freehand-draw.d.ts +61 -0
  22. package/src/image-editor/action/freehand-draw.js +1015 -0
  23. package/src/image-editor/action/index.d.ts +9 -0
  24. package/src/image-editor/action/index.js +9 -0
  25. package/src/image-editor/action/selection.d.ts +140 -0
  26. package/src/image-editor/action/selection.js +4689 -0
  27. package/src/image-editor/action/shape.d.ts +93 -0
  28. package/src/image-editor/action/shape.js +2657 -0
  29. package/src/image-editor/action/transform.d.ts +67 -0
  30. package/src/image-editor/action/transform.js +1670 -0
  31. package/src/image-editor/action/undo-redo.d.ts +43 -0
  32. package/src/image-editor/action/undo-redo.js +800 -0
  33. package/src/image-editor/base/enum.d.ts +189 -0
  34. package/src/image-editor/base/enum.js +198 -0
  35. package/src/image-editor/{image-editor-model.d.ts → base/image-editor-model.d.ts} +131 -43
  36. package/src/image-editor/{image-editor.d.ts → base/image-editor.d.ts} +425 -1108
  37. package/src/image-editor/base/image-editor.js +2458 -0
  38. package/src/image-editor/base/index.d.ts +4 -0
  39. package/src/image-editor/base/index.js +2 -0
  40. package/src/image-editor/base/interface.d.ts +1120 -0
  41. package/src/image-editor/base/interface.js +1 -0
  42. package/src/image-editor/index.d.ts +3 -5
  43. package/src/image-editor/index.js +3 -4
  44. package/src/image-editor/renderer/index.d.ts +1 -0
  45. package/src/image-editor/renderer/index.js +1 -0
  46. package/src/image-editor/renderer/toolbar.d.ts +105 -0
  47. package/src/image-editor/renderer/toolbar.js +3019 -0
  48. package/styles/bootstrap-dark.css +69 -3
  49. package/styles/bootstrap.css +69 -3
  50. package/styles/bootstrap4.css +69 -3
  51. package/styles/bootstrap5-dark.css +69 -3
  52. package/styles/bootstrap5.css +69 -3
  53. package/styles/fabric-dark.css +69 -3
  54. package/styles/fabric.css +69 -3
  55. package/styles/fluent-dark.css +69 -3
  56. package/styles/fluent.css +69 -3
  57. package/styles/highcontrast-light.css +69 -3
  58. package/styles/highcontrast.css +69 -7
  59. package/styles/image-editor/_layout.scss +21 -7
  60. package/styles/image-editor/_material3-dark-definition.scss +1 -0
  61. package/styles/image-editor/_material3-definition.scss +11 -0
  62. package/styles/image-editor/_theme.scss +9 -2
  63. package/styles/image-editor/bootstrap-dark.css +69 -3
  64. package/styles/image-editor/bootstrap.css +69 -3
  65. package/styles/image-editor/bootstrap4.css +69 -3
  66. package/styles/image-editor/bootstrap5-dark.css +69 -3
  67. package/styles/image-editor/bootstrap5.css +69 -3
  68. package/styles/image-editor/fabric-dark.css +69 -3
  69. package/styles/image-editor/fabric.css +69 -3
  70. package/styles/image-editor/fluent-dark.css +69 -3
  71. package/styles/image-editor/fluent.css +69 -3
  72. package/styles/image-editor/highcontrast-light.css +69 -3
  73. package/styles/image-editor/highcontrast.css +69 -7
  74. package/styles/image-editor/icons/_bootstrap-dark.scss +132 -0
  75. package/styles/image-editor/icons/_bootstrap.scss +132 -0
  76. package/styles/image-editor/icons/_bootstrap4.scss +132 -0
  77. package/styles/image-editor/icons/_bootstrap5.scss +132 -0
  78. package/styles/image-editor/icons/_fabric-dark.scss +132 -0
  79. package/styles/image-editor/icons/_fabric.scss +132 -0
  80. package/styles/image-editor/icons/_fluent.scss +132 -0
  81. package/styles/image-editor/icons/_fusionnew.scss +132 -0
  82. package/styles/image-editor/icons/_highcontrast-light.scss +132 -0
  83. package/styles/image-editor/icons/_highcontrast.scss +132 -0
  84. package/styles/image-editor/icons/_material-dark.scss +132 -0
  85. package/styles/image-editor/icons/_material.scss +132 -0
  86. package/styles/image-editor/icons/_material3-dark.scss +1 -0
  87. package/styles/image-editor/icons/_material3.scss +133 -1
  88. package/styles/image-editor/icons/_tailwind.scss +132 -0
  89. package/styles/image-editor/material-dark.css +69 -3
  90. package/styles/image-editor/material.css +69 -3
  91. package/styles/image-editor/material3-dark.css +453 -0
  92. package/styles/image-editor/material3-dark.scss +14 -0
  93. package/styles/image-editor/material3.css +509 -0
  94. package/styles/image-editor/material3.scss +14 -0
  95. package/styles/image-editor/tailwind-dark.css +69 -3
  96. package/styles/image-editor/tailwind.css +69 -3
  97. package/styles/material-dark.css +69 -3
  98. package/styles/material.css +69 -3
  99. package/styles/material3-dark.css +453 -0
  100. package/styles/material3-dark.scss +3 -0
  101. package/styles/material3.css +509 -0
  102. package/styles/material3.scss +3 -0
  103. package/styles/tailwind-dark.css +69 -3
  104. package/styles/tailwind.css +69 -3
  105. package/src/image-editor/image-editor.js +0 -14784
@@ -0,0 +1,818 @@
1
+ import { extend, isBlazor, isNullOrUndefined } from '@syncfusion/ej2-base';
2
+ var Crop = /** @class */ (function () {
3
+ function Crop(parent) {
4
+ this.croppedDegree = 0; // Specifies the degree when crop is performed
5
+ this.cropDestPoints = { startX: 0, startY: 0, width: 0, height: 0 }; // To redraw old image when navigate to crop tab
6
+ this.tempFlipPanPoint = { x: 0, y: 0 };
7
+ this.parent = parent;
8
+ this.addEventListener();
9
+ }
10
+ Crop.prototype.destroy = function () {
11
+ if (this.parent.isDestroyed) {
12
+ return;
13
+ }
14
+ this.removeEventListener();
15
+ };
16
+ Crop.prototype.addEventListener = function () {
17
+ this.parent.on('crop', this.cropping, this);
18
+ this.parent.on('destroyed', this.destroy, this);
19
+ };
20
+ Crop.prototype.removeEventListener = function () {
21
+ this.parent.off('crop', this.crop);
22
+ this.parent.off('destroyed', this.destroy);
23
+ };
24
+ Crop.prototype.cropping = function (args) {
25
+ this.updateCropPvtVar();
26
+ switch (args.prop) {
27
+ case 'cropImg':
28
+ this.cropImg(args.value['isRotateCrop']);
29
+ break;
30
+ case 'cropCircle':
31
+ this.cropCircle(args.value['context'], args.value['isSave'], args.value['isFlip']);
32
+ break;
33
+ case 'setCurrSelPoints':
34
+ this.setCurrSelPoints(args.value['isSetDimension']);
35
+ break;
36
+ case 'updateRotatePan':
37
+ this.updateRotatePan();
38
+ break;
39
+ case 'crop':
40
+ this.crop(args.value['obj']);
41
+ break;
42
+ case 'calcRatio':
43
+ this.calcRatio(args.value['obj']);
44
+ break;
45
+ case 'isObjInImage':
46
+ this.isObjInImage(args.value['obj'], args.value['object']);
47
+ break;
48
+ case 'getCurrFlipState':
49
+ this.getCurrFlipState(args.value['panObj']);
50
+ break;
51
+ case 'setPreviousCropCurrentObj':
52
+ this.prevCropCurrObj = args.value['obj'];
53
+ break;
54
+ case 'setCropDestPoints':
55
+ this.cropDestPoints = args.value['point'];
56
+ break;
57
+ case 'getTempFlipPanPoint':
58
+ args.value['obj']['point'] = this.tempFlipPanPoint;
59
+ break;
60
+ case 'setTempFlipPanPoint':
61
+ if (isNullOrUndefined(args.value['isAdd'])) {
62
+ this.tempFlipPanPoint = args.value['point'];
63
+ }
64
+ else {
65
+ this.tempFlipPanPoint.x += args.value['point'].x;
66
+ this.tempFlipPanPoint.y += args.value['point'].y;
67
+ }
68
+ break;
69
+ case 'reset':
70
+ this.reset();
71
+ break;
72
+ }
73
+ };
74
+ Crop.prototype.getModuleName = function () {
75
+ return 'crop';
76
+ };
77
+ Crop.prototype.updateCropPvtVar = function () {
78
+ var parent = this.parent;
79
+ if (parent.lowerCanvas) {
80
+ this.lowerContext = parent.lowerCanvas.getContext('2d');
81
+ }
82
+ if (parent.upperCanvas) {
83
+ this.upperContext = parent.upperCanvas.getContext('2d');
84
+ }
85
+ };
86
+ Crop.prototype.reset = function () {
87
+ this.prevCropCurrObj = null;
88
+ this.croppedDegree = 0;
89
+ this.cropDestPoints = { startX: 0, startY: 0, width: 0, height: 0 };
90
+ this.tempFlipPanPoint = { x: 0, y: 0 };
91
+ };
92
+ Crop.prototype.cropImg = function (isRotateCrop) {
93
+ var parent = this.parent;
94
+ var isNullCrop = isNullOrUndefined(isRotateCrop);
95
+ var actPoint = parent.activeObj.activePoint;
96
+ parent.notify('draw', { prop: 'setImageEdited', onPropertyChange: false });
97
+ if (isNullCrop) {
98
+ this.croppedDegree = parent.transform.degree;
99
+ }
100
+ if (isNullCrop && parent.transform.degree !== 0) {
101
+ this.updateCropObj();
102
+ var point = { startX: parent.img.destLeft, startY: parent.img.destTop, width: parent.img.destWidth,
103
+ height: parent.img.destHeight };
104
+ parent.notify('transform', { prop: 'setCurrDestinationPoint', onPropertyChange: false, value: { point: point } });
105
+ this.rotateCrop();
106
+ }
107
+ else if (isNullCrop && parent.transform.currFlipState !== '') {
108
+ this.updateCropObj();
109
+ var point = { startX: parent.img.destLeft, startY: parent.img.destTop, width: parent.img.destWidth,
110
+ height: parent.img.destHeight };
111
+ parent.notify('transform', { prop: 'setCurrDestinationPoint', onPropertyChange: false, value: { point: point } });
112
+ this.flipCrop();
113
+ }
114
+ else {
115
+ parent.notify('draw', { prop: 'setTempZoomFactor', onPropertyChange: false, value: { tempZoomFactor: parent.transform.zoomFactor } });
116
+ var ratio = this.calcRatio();
117
+ if (isNullCrop || !isRotateCrop) { // isRotateCrop is NULL or False
118
+ this.updateCropObj();
119
+ parent.notify('draw', { prop: 'resetPanPoints', onPropertyChange: false });
120
+ parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
121
+ var point = { startX: parent.img.destLeft, startY: parent.img.destTop, width: parent.img.destWidth,
122
+ height: parent.img.destHeight };
123
+ parent.notify('transform', { prop: 'setCurrDestinationPoint', onPropertyChange: false, value: { point: point } });
124
+ parent.currSelectionPoint = extend({}, parent.activeObj, {}, true);
125
+ this.cropDestPoints = { startX: parent.img.destLeft, startY: parent.img.destTop, width: parent.img.destWidth,
126
+ height: parent.img.destHeight };
127
+ }
128
+ var obj = { width: 0, height: 0 };
129
+ parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
130
+ value: { width: actPoint.width * ratio.width,
131
+ height: actPoint.height * ratio.height, obj: obj } });
132
+ var maxDimension = obj;
133
+ this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
134
+ this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
135
+ parent.img.srcLeft = (actPoint.startX * ratio.width) - (parent.img.destLeft * ratio.width);
136
+ parent.img.srcTop = (actPoint.startY * ratio.height) - (parent.img.destTop * ratio.height);
137
+ parent.img.srcWidth = (actPoint.width * ratio.width);
138
+ parent.img.srcHeight = (actPoint.height * ratio.height);
139
+ parent.img.destLeft = (parent.lowerCanvas.clientWidth - maxDimension.width) / 2;
140
+ parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.height) / 2;
141
+ parent.img.destWidth = maxDimension.width;
142
+ parent.img.destHeight = maxDimension.height;
143
+ var temp = this.lowerContext.filter;
144
+ parent.notify('finetune', { prop: 'updateBrightFilter', onPropertyChange: false });
145
+ 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);
146
+ this.lowerContext.filter = 'none';
147
+ var activeObj = extend({}, parent.activeObj, {}, true);
148
+ this.cropObjColl();
149
+ parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
150
+ for (var i = 0, len = parent.objColl.length; i < len; i++) {
151
+ if (this.isObjInImage(parent.objColl[i])) {
152
+ parent.notify('shape', { prop: 'apply', onPropertyChange: false,
153
+ value: { shape: parent.objColl[i].shape, obj: parent.objColl[i], canvas: null } });
154
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
155
+ }
156
+ }
157
+ parent.activeObj = activeObj;
158
+ this.cropFreehandDrawColl();
159
+ parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
160
+ parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
161
+ parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
162
+ if (parent.currSelectionPoint.shape === 'crop-circle') {
163
+ this.cropCircle(this.lowerContext);
164
+ }
165
+ else {
166
+ parent.isCircleCrop = false;
167
+ }
168
+ this.lowerContext.filter = temp;
169
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
170
+ parent.currObjType.isCustomCrop = false;
171
+ parent.pan(false);
172
+ parent.transform.defaultZoomFactor = 0;
173
+ }
174
+ };
175
+ Crop.prototype.updateCropObj = function () {
176
+ this.parent.afterCropActions = [];
177
+ var object = { currObj: {} };
178
+ this.parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
179
+ var obj = object['currObj'];
180
+ this.parent.cropObj = extend({}, obj, {}, true);
181
+ };
182
+ Crop.prototype.rotateCrop = function () {
183
+ var parent = this.parent;
184
+ var shape = parent.activeObj.shape || '';
185
+ var tempDegree = parent.transform.degree;
186
+ parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
187
+ parent.currSelectionPoint = extend({}, parent.activeObj, {}, true);
188
+ parent.objColl.push(parent.activeObj);
189
+ parent.activeObj = extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
190
+ this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
191
+ parent.notify('draw', { prop: 'setClientTransDim', onPropertyChange: false,
192
+ value: { isPreventDimension: null } });
193
+ this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
194
+ parent.transform.degree = 0;
195
+ var temp = this.lowerContext.filter;
196
+ parent.notify('finetune', { prop: 'updateBrightFilter', onPropertyChange: false });
197
+ 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);
198
+ this.lowerContext.filter = temp;
199
+ var length = 0;
200
+ if (tempDegree === 90 || tempDegree === -270) {
201
+ length = 3;
202
+ }
203
+ else if (tempDegree === 180 || tempDegree === -180) {
204
+ length = 2;
205
+ }
206
+ else if (tempDegree === 270 || tempDegree === -90) {
207
+ length = 1;
208
+ }
209
+ for (var i = 0; i < length; i++) {
210
+ parent.notify('shape', { prop: 'rotateObjColl', onPropertyChange: false });
211
+ parent.notify('freehand-draw', { prop: 'rotateFhdColl', onPropertyChange: false });
212
+ }
213
+ var activeObj = extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
214
+ if (parent.transform.currFlipState !== '') {
215
+ for (var i = 0, len = parent.objColl.length; i < len; i++) {
216
+ parent.objColl[i].shapeFlip = '';
217
+ }
218
+ for (var i = 0; i < parent.freehandCounter; i++) {
219
+ parent.pointColl[i].shapeFlip = '';
220
+ }
221
+ parent.transform.degree = tempDegree;
222
+ var flipState = this.getCurrCropState('initial');
223
+ parent.transform.degree = 0;
224
+ parent.notify('shape', { prop: 'redrawObj', onPropertyChange: false, value: { degree: flipState } });
225
+ parent.notify('freehand-draw', { prop: 'flipFHDColl', onPropertyChange: false,
226
+ value: { value: flipState } });
227
+ }
228
+ parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
229
+ parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
230
+ activeObj = extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
231
+ this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
232
+ parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: activeObj } });
233
+ parent.objColl.pop();
234
+ parent.transform.degree = 0;
235
+ this.cropImg(true);
236
+ parent.notify('transform', { prop: 'setReverseRotate', onPropertyChange: false, value: { bool: true } });
237
+ this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
238
+ parent.transform.degree = tempDegree;
239
+ parent.notify('draw', { prop: 'setDestPoints', onPropertyChange: false });
240
+ parent.notify('draw', { prop: 'currTransState', onPropertyChange: false,
241
+ value: { type: 'initial', isPreventDestination: null, context: null, isPreventCircleCrop: null } });
242
+ parent.notify('finetune', { prop: 'updateBrightFilter', onPropertyChange: false });
243
+ 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);
244
+ this.lowerContext.filter = temp;
245
+ parent.notify('draw', { prop: 'currTransState', onPropertyChange: false,
246
+ value: { type: 'reverse', isPreventDestination: null, context: null, isPreventCircleCrop: null } });
247
+ length = 0;
248
+ if (tempDegree === 90 || tempDegree === -270) {
249
+ length = 1;
250
+ }
251
+ else if (tempDegree === 180 || tempDegree === -180) {
252
+ length = 2;
253
+ }
254
+ else if (tempDegree === 270 || tempDegree === -90) {
255
+ length = 3;
256
+ }
257
+ for (var i = 0; i < length; i++) {
258
+ parent.notify('shape', { prop: 'rotateObjColl', onPropertyChange: false });
259
+ parent.notify('freehand-draw', { prop: 'rotateFhdColl', onPropertyChange: false });
260
+ }
261
+ if (this.getCurrFlipState() !== '') {
262
+ for (var i = 0, len = parent.objColl.length; i < len; i++) {
263
+ parent.objColl[i].shapeFlip = '';
264
+ }
265
+ for (var i = 0; i < parent.freehandCounter; i++) {
266
+ parent.pointColl[i].shapeFlip = '';
267
+ }
268
+ var flipState = this.getCurrCropState('reverse');
269
+ parent.notify('shape', { prop: 'redrawObj', onPropertyChange: false, value: { degree: flipState } });
270
+ parent.notify('freehand-draw', { prop: 'flipFHDColl', onPropertyChange: false,
271
+ value: { value: flipState } });
272
+ }
273
+ parent.notify('transform', { prop: 'setReverseRotate', onPropertyChange: false, value: { bool: false } });
274
+ this.lowerContext.filter = 'none';
275
+ for (var i = 0, len = parent.objColl.length; i < len; i++) {
276
+ if (this.isObjInImage(parent.objColl[i])) {
277
+ parent.notify('shape', { prop: 'apply', onPropertyChange: false,
278
+ value: { shape: parent.objColl[i].shape, obj: parent.objColl[i], canvas: null } });
279
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
280
+ }
281
+ }
282
+ parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
283
+ this.lowerContext.filter = temp;
284
+ parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
285
+ parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
286
+ if (shape === 'crop-circle') {
287
+ this.cropCircle(this.lowerContext);
288
+ }
289
+ this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
290
+ parent.notify('draw', { prop: 'resetPanPoints', onPropertyChange: false });
291
+ };
292
+ Crop.prototype.flipCrop = function () {
293
+ var parent = this.parent;
294
+ parent.notify('transform', { prop: 'setReverseFlip', onPropertyChange: false, value: { isReverseFlip: true } });
295
+ parent.panPoint.totalPannedPoint.x += this.tempFlipPanPoint.x;
296
+ parent.panPoint.totalPannedPoint.y += this.tempFlipPanPoint.y;
297
+ var tempCurrFlipState = parent.transform.currFlipState;
298
+ var obj = { flipColl: null };
299
+ parent.notify('transform', { prop: 'getFlipColl', onPropertyChange: false, value: { obj: obj } });
300
+ var tempFlipColl = obj['flipColl'];
301
+ parent.notify('transform', { prop: 'setFlipColl', onPropertyChange: false, value: { flipColl: [] } });
302
+ parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
303
+ parent.objColl.push(parent.activeObj);
304
+ if (parent.transform.zoomFactor > 0) {
305
+ var zoomFactor = parent.transform.zoomFactor;
306
+ var isUndoRedo = parent.isUndoRedo;
307
+ for (var i = 0; i < (zoomFactor * 10); i++) {
308
+ parent.isUndoRedo = true;
309
+ parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
310
+ value: { zoomFactor: -0.1, zoomPoint: null } });
311
+ }
312
+ parent.isUndoRedo = isUndoRedo;
313
+ parent.notify('draw', { prop: 'resetPanPoints', onPropertyChange: false });
314
+ }
315
+ parent.currSelectionPoint = extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
316
+ this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
317
+ this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
318
+ var temp = this.lowerContext.filter;
319
+ parent.notify('finetune', { prop: 'updateBrightFilter', onPropertyChange: false });
320
+ 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);
321
+ for (var i = 0, len = parent.objColl.length; i < len; i++) {
322
+ parent.objColl[i].shapeFlip = '';
323
+ }
324
+ for (var i = 0; i < parent.freehandCounter; i++) {
325
+ parent.pointColl[i].shapeFlip = '';
326
+ }
327
+ parent.notify('shape', { prop: 'redrawObj', onPropertyChange: false, value: { degree: this.getCurrFlipState() } });
328
+ parent.notify('freehand-draw', { prop: 'flipFHDColl', onPropertyChange: false,
329
+ value: { value: this.getCurrFlipState() } });
330
+ parent.activeObj = extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
331
+ parent.objColl.pop();
332
+ this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
333
+ parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
334
+ this.cropImg(true);
335
+ parent.notify('transform', { prop: 'setReverseRotate', onPropertyChange: false, value: { bool: true } });
336
+ this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
337
+ parent.notify('draw', { prop: 'setDestPoints', onPropertyChange: false });
338
+ parent.notify('draw', { prop: 'currTransState', onPropertyChange: false,
339
+ value: { type: 'initial', isPreventDestination: null, context: null, isPreventCircleCrop: null } });
340
+ parent.notify('finetune', { prop: 'updateBrightFilter', onPropertyChange: false });
341
+ 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);
342
+ this.lowerContext.filter = temp;
343
+ parent.notify('draw', { prop: 'setRotateZoom', onPropertyChange: false, value: { isRotateZoom: false } });
344
+ parent.notify('draw', { prop: 'currTransState', onPropertyChange: false,
345
+ value: { type: 'reverse', isPreventDestination: null, context: null, isPreventCircleCrop: null } });
346
+ parent.transform.currFlipState = tempCurrFlipState;
347
+ parent.notify('transform', { prop: 'setFlipColl', onPropertyChange: false, value: { flipColl: tempFlipColl } });
348
+ this.lowerContext.filter = 'none';
349
+ for (var i = 0, len = parent.objColl.length; i < len; i++) {
350
+ parent.objColl[i].shapeFlip = '';
351
+ }
352
+ for (var i = 0; i < parent.freehandCounter; i++) {
353
+ parent.pointColl[i].shapeFlip = '';
354
+ }
355
+ parent.notify('shape', { prop: 'redrawObj', onPropertyChange: false, value: { degree: this.getCurrFlipState() } });
356
+ parent.notify('freehand-draw', { prop: 'flipFHDColl', onPropertyChange: false,
357
+ value: { value: this.getCurrFlipState() } });
358
+ parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
359
+ parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
360
+ this.lowerContext.filter = temp;
361
+ if ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
362
+ this.cropCircle(this.lowerContext);
363
+ }
364
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
365
+ parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
366
+ parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
367
+ this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
368
+ parent.notify('transform', { prop: 'setReverseFlip', onPropertyChange: false, value: { isReverseFlip: false } });
369
+ parent.notify('draw', { prop: 'resetPanPoints', onPropertyChange: false });
370
+ this.tempFlipPanPoint = { x: 0, y: 0 };
371
+ };
372
+ Crop.prototype.cropObjColl = function () {
373
+ var parent = this.parent;
374
+ var point;
375
+ var activePoint;
376
+ var shape;
377
+ if (parent.objColl.length > 0) {
378
+ for (var i = 0, len = parent.objColl.length; i < len; i++) {
379
+ point = parent.objColl[i].activePoint;
380
+ activePoint = parent.activeObj.activePoint;
381
+ shape = parent.objColl[i].shape;
382
+ parent.objColl[i].imageRatio = { startX: ((point.startX - activePoint.startX) / activePoint.width),
383
+ startY: ((point.startY - activePoint.startY) / activePoint.height),
384
+ endX: ((point.endX - activePoint.startX) / activePoint.width),
385
+ endY: ((point.endY - activePoint.startY) / activePoint.height),
386
+ width: activePoint.width / point.width,
387
+ height: activePoint.height / point.height };
388
+ var degree = void 0;
389
+ var size = void 0;
390
+ switch (shape) {
391
+ case 'text':
392
+ if (parent.objColl[i].shapeDegree === 0) {
393
+ degree = this.parent.transform.degree;
394
+ }
395
+ else {
396
+ degree = this.parent.transform.degree - parent.objColl[i].shapeDegree;
397
+ }
398
+ size = (degree === 0 || Math.abs(degree) === 180) ? point.width : point.height;
399
+ parent.objColl[i].textSettings.fontRatio = size / parent.objColl[i].textSettings.fontSize;
400
+ break;
401
+ case 'line':
402
+ case 'arrow':
403
+ this.cropPointCollection(i);
404
+ if (shape === 'arrow') {
405
+ parent.notify('shape', { prop: 'updateArrowRatio', onPropertyChange: false, value: { obj: parent.objColl[i] } });
406
+ }
407
+ break;
408
+ case 'path':
409
+ this.cropPointCollection(i);
410
+ break;
411
+ }
412
+ }
413
+ }
414
+ };
415
+ Crop.prototype.cropPointCollection = function (i) {
416
+ var parent = this.parent;
417
+ var shape = parent.objColl[i].shape;
418
+ var x;
419
+ var y;
420
+ var width;
421
+ var height;
422
+ var point = parent.activeObj.activePoint;
423
+ if (shape === 'path') {
424
+ x = point.startX;
425
+ y = point.startY;
426
+ width = point.width;
427
+ height = point.height;
428
+ }
429
+ else {
430
+ x = parent.img.destLeft;
431
+ y = parent.img.destTop;
432
+ width = parent.img.destWidth;
433
+ height = parent.img.destHeight;
434
+ }
435
+ var selPoint = parent.objColl[i];
436
+ for (var n = 0, len = selPoint.pointColl.length; n < len; n++) {
437
+ selPoint.pointColl[n].ratioX =
438
+ (selPoint.pointColl[n].x - x) / width;
439
+ selPoint.pointColl[n].ratioY =
440
+ (selPoint.pointColl[n].y - y) / height;
441
+ }
442
+ };
443
+ Crop.prototype.cropFreehandDrawColl = function () {
444
+ var parent = this.parent;
445
+ // Update crop values to point collection
446
+ for (var n = 0; n < parent.freehandCounter; n++) {
447
+ parent.points = extend([], parent.pointColl[n].points, []);
448
+ parent.notify('freehand-draw', { prop: 'setPointCounter', onPropertyChange: false, value: { value: 0 } });
449
+ var len = parent.points.length;
450
+ for (var l = 0; l < len; l++) {
451
+ parent.points[l].ratioX = (parent.points[l].x -
452
+ parent.activeObj.activePoint.startX) / parent.activeObj.activePoint.width;
453
+ parent.points[l].ratioY = (parent.points[l].y -
454
+ parent.activeObj.activePoint.startY) / parent.activeObj.activePoint.height;
455
+ }
456
+ }
457
+ parent.notify('freehand-draw', { prop: 'updateCropPtsForSel', onPropertyChange: false });
458
+ };
459
+ Crop.prototype.setCurrSelPoints = function (isSetDimension) {
460
+ var parent = this.parent;
461
+ var destPoint = this.cropDestPoints;
462
+ parent.img.srcLeft = 0;
463
+ parent.img.srcTop = 0;
464
+ parent.img.srcWidth = parent.baseImg.width;
465
+ parent.img.srcHeight = parent.baseImg.height;
466
+ parent.img.destLeft = destPoint.startX;
467
+ parent.img.destTop = destPoint.startY;
468
+ parent.img.destWidth = destPoint.width;
469
+ parent.img.destHeight = destPoint.height;
470
+ this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
471
+ if (isSetDimension) {
472
+ parent.notify('draw', { prop: 'setDestPoints', onPropertyChange: false });
473
+ }
474
+ parent.notify('draw', { prop: 'currTransState', onPropertyChange: false,
475
+ value: { type: 'initial', isPreventDestination: null, context: null, isPreventCircleCrop: null } });
476
+ if (this.croppedDegree === 0 && parent.transform.degree === 0 && parent.currSelectionPoint
477
+ && parent.currSelectionPoint.shape !== 'crop-circle' && parent.currSelectionPoint.shape !== 'crop-square') {
478
+ parent.img.destLeft = destPoint.startX;
479
+ parent.img.destTop = destPoint.startY;
480
+ parent.img.destWidth = destPoint.width;
481
+ parent.img.destHeight = destPoint.height;
482
+ }
483
+ if (parent.transform.degree === 0) {
484
+ parent.img.destLeft += parent.panPoint.totalPannedInternalPoint.x;
485
+ parent.img.destTop += parent.panPoint.totalPannedInternalPoint.y;
486
+ }
487
+ parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
488
+ 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);
489
+ parent.notify('draw', { prop: 'currTransState', onPropertyChange: false,
490
+ value: { type: 'reverse', isPreventDestination: null, context: null, isPreventCircleCrop: true } });
491
+ if (parent.cropObj.activeObj.shape) {
492
+ var destPoints = { startX: parent.img.destLeft, startY: parent.img.destTop, width: parent.img.destWidth,
493
+ height: parent.img.destHeight };
494
+ if (parent.currSelectionPoint && parent.currSelectionPoint.activePoint) {
495
+ parent.img.destLeft = parent.currSelectionPoint.activePoint.startX;
496
+ parent.img.destTop = parent.currSelectionPoint.activePoint.startY;
497
+ parent.img.destWidth = parent.currSelectionPoint.activePoint.width;
498
+ parent.img.destHeight = parent.currSelectionPoint.activePoint.height;
499
+ }
500
+ parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
501
+ parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
502
+ parent.img.destLeft = destPoints.startX;
503
+ parent.img.destTop = destPoints.startY;
504
+ parent.img.destWidth = destPoints.width;
505
+ parent.img.destHeight = destPoints.height;
506
+ parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false });
507
+ var cropObjColl = extend([], parent.objColl, null, true);
508
+ var cropPointColl = extend([], parent.pointColl, null, true);
509
+ parent.objColl = [];
510
+ parent.pointColl = [];
511
+ parent.freehandCounter = 0;
512
+ var object = { selPointColl: null };
513
+ parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
514
+ value: { obj: object } });
515
+ var cropSelPointColl = object['selPointColl'];
516
+ parent.notify('freehand-draw', { prop: 'setSelPointColl', onPropertyChange: false,
517
+ value: { obj: { selPointColl: [] } } });
518
+ parent.cropObj.filter = this.lowerContext.filter;
519
+ parent.notify('draw', { prop: 'setCurrentObj', onPropertyChange: false, value: { obj: null } });
520
+ var activeObj = extend({}, parent.activeObj, null, true);
521
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
522
+ parent.objColl = cropObjColl;
523
+ parent.pointColl = cropPointColl;
524
+ parent.freehandCounter = parent.pointColl.length;
525
+ parent.notify('freehand-draw', { prop: 'setSelPointColl', onPropertyChange: false,
526
+ value: { obj: { selPointColl: cropSelPointColl } } });
527
+ parent.notify('shape', { prop: 'iterateObjColl', onPropertyChange: false });
528
+ parent.notify('freehand-draw', { prop: 'freehandRedraw', onPropertyChange: false,
529
+ value: { context: this.lowerContext, points: null } });
530
+ parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false });
531
+ parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
532
+ parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
533
+ parent.currSelectionPoint = null;
534
+ if (parent.transform.degree === 0) {
535
+ parent.notify('transform', { prop: 'drawPannImage', onPropertyChange: false,
536
+ value: { point: { x: 0, y: 0 } } });
537
+ }
538
+ parent.activeObj = activeObj;
539
+ parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
540
+ parent.notify('transform', { prop: 'setTempPanMove', onPropertyChange: false,
541
+ value: { point: null } });
542
+ }
543
+ else {
544
+ var temp = this.lowerContext.filter;
545
+ this.lowerContext.filter = 'none';
546
+ parent.notify('shape', { prop: 'iterateObjColl', onPropertyChange: false });
547
+ parent.notify('freehand-draw', { prop: 'freehandRedraw', onPropertyChange: false,
548
+ value: { context: this.lowerContext, points: null } });
549
+ this.lowerContext.filter = temp;
550
+ parent.currSelectionPoint = null;
551
+ }
552
+ };
553
+ Crop.prototype.cropCircle = function (context, isSave, isFlip) {
554
+ var parent = this.parent;
555
+ if (isFlip && parent.transform.currFlipState !== '') {
556
+ parent.notify('draw', { prop: 'setTransform', onPropertyChange: false,
557
+ value: { context: context, value: parent.transform.currFlipState, isReverse: null } });
558
+ }
559
+ context.globalCompositeOperation = 'destination-in';
560
+ context.beginPath();
561
+ var centerX = isNullOrUndefined(isSave) ? parent.img.destLeft + (parent.img.destWidth / 2) : parent.img.destWidth / 2;
562
+ var centerY = isNullOrUndefined(isSave) ? parent.img.destTop + (parent.img.destHeight / 2) : parent.img.destHeight / 2;
563
+ var radius = parent.img.destWidth / 2;
564
+ context.arc(centerX, centerY, radius, 0, Math.PI * 2);
565
+ context.closePath();
566
+ context.fill();
567
+ context.restore();
568
+ context.globalCompositeOperation = 'source-over';
569
+ parent.currObjType.isActiveObj = parent.isCircleCrop = true;
570
+ if (isFlip && parent.transform.currFlipState !== '') {
571
+ parent.notify('draw', { prop: 'setTransform', onPropertyChange: false,
572
+ value: { context: context, value: parent.transform.currFlipState, isReverse: null } });
573
+ }
574
+ };
575
+ Crop.prototype.getCurrCropState = function (type, isAllowInvert) {
576
+ var parent = this.parent;
577
+ var flipState = '';
578
+ var state = [];
579
+ var obj = { flipColl: null };
580
+ parent.notify('transform', { prop: 'getFlipColl', onPropertyChange: false, value: { obj: obj } });
581
+ if (type === 'initial') {
582
+ if (Math.abs(parent.transform.degree) === 180) {
583
+ flipState = obj['flipColl'].length > 1 ? this.getCurrFlipState() : parent.transform.currFlipState;
584
+ }
585
+ else {
586
+ for (var i = 0, len = parent.rotateFlipColl.length; i < len; i++) {
587
+ if (typeof (parent.rotateFlipColl[i]) === 'number') {
588
+ state.push('number');
589
+ }
590
+ else if (typeof (parent.rotateFlipColl[i]) === 'string') {
591
+ state.push('string');
592
+ }
593
+ }
594
+ if (state.length > 1 && state[state.length - 1] === 'string' && state[state.length - 2] === 'number') {
595
+ if (parent.transform.currFlipState === 'horizontal') {
596
+ flipState = 'vertical';
597
+ }
598
+ else if (parent.transform.currFlipState === 'vertical') {
599
+ flipState = 'horizontal';
600
+ }
601
+ }
602
+ else if (state.length > 1 && state[state.length - 1] === 'number' && state[state.length - 2] === 'string') {
603
+ flipState = obj['flipColl'].length > 1 ? this.getCurrFlipState() : parent.transform.currFlipState;
604
+ }
605
+ }
606
+ }
607
+ else {
608
+ flipState = this.getCurrFlipState();
609
+ if (isAllowInvert || !this.isInitialRotate()) {
610
+ if (parent.transform.degree === -90 || parent.transform.degree === -270) {
611
+ if (flipState === 'horizontal') {
612
+ flipState = 'vertical';
613
+ }
614
+ else if (flipState === 'vertical') {
615
+ flipState = 'horizontal';
616
+ }
617
+ }
618
+ }
619
+ }
620
+ if (flipState === '') {
621
+ flipState = obj['flipColl'].length > 1 ? this.getCurrFlipState() : parent.transform.currFlipState;
622
+ }
623
+ return flipState;
624
+ };
625
+ Crop.prototype.isInitialRotate = function () {
626
+ var isRotate = false;
627
+ if (this.parent.rotateFlipColl.length > 0 && typeof (this.parent.rotateFlipColl[0]) === 'number') {
628
+ isRotate = true;
629
+ }
630
+ return isRotate;
631
+ };
632
+ Crop.prototype.updateRotatePan = function () {
633
+ var parent = this.parent;
634
+ if (isNullOrUndefined(parent.panPoint.currentPannedPoint)) {
635
+ return;
636
+ }
637
+ var panRegion = '';
638
+ if (parent.rotateFlipColl.length > 0 && typeof (parent.rotateFlipColl[0]) === 'number'
639
+ && parent.transform.degree < 0) {
640
+ panRegion = this.getCurrCropState('reverse', true);
641
+ }
642
+ else {
643
+ panRegion = this.getCurrFlipState();
644
+ }
645
+ if (parent.transform.degree % 90 === 0 && parent.transform.degree % 180 !== 0) {
646
+ if (parent.transform.degree === 90 || (parent.transform.degree === -90 &&
647
+ (panRegion === 'horizontal' || panRegion === 'vertical'))
648
+ || (parent.transform.degree === -270 && (panRegion === '' || panRegion === 'verticalHorizontal'
649
+ || panRegion === 'horizontalVertical'))) {
650
+ if (panRegion === 'horizontal' || panRegion === '') {
651
+ parent.img.destLeft += parent.panPoint.currentPannedPoint.y;
652
+ }
653
+ else {
654
+ parent.img.destLeft -= parent.panPoint.currentPannedPoint.y;
655
+ }
656
+ if (panRegion === '' || panRegion === 'vertical') {
657
+ parent.img.destTop -= parent.panPoint.currentPannedPoint.x;
658
+ }
659
+ else {
660
+ parent.img.destTop += parent.panPoint.currentPannedPoint.x;
661
+ }
662
+ }
663
+ else if (parent.transform.degree === 270 || (parent.transform.degree === -270 &&
664
+ (panRegion === 'horizontal' || panRegion === 'vertical'))
665
+ || (parent.transform.degree === -90 && (panRegion === '' || panRegion === 'verticalHorizontal'
666
+ || panRegion === 'horizontalVertical'))) {
667
+ if (panRegion === '' || panRegion === 'horizontal') {
668
+ parent.img.destLeft -= parent.panPoint.currentPannedPoint.y;
669
+ }
670
+ else {
671
+ parent.img.destLeft += parent.panPoint.currentPannedPoint.y;
672
+ }
673
+ if (panRegion === '' || panRegion === 'vertical') {
674
+ parent.img.destTop += parent.panPoint.currentPannedPoint.x;
675
+ }
676
+ else {
677
+ parent.img.destTop -= parent.panPoint.currentPannedPoint.x;
678
+ }
679
+ }
680
+ }
681
+ else {
682
+ if (parent.transform.degree === 180 || parent.transform.degree === -180) {
683
+ if (panRegion === '' || panRegion === 'vertical') {
684
+ parent.img.destLeft -= parent.panPoint.currentPannedPoint.x;
685
+ }
686
+ else {
687
+ parent.img.destLeft += parent.panPoint.currentPannedPoint.x;
688
+ }
689
+ if (panRegion === '' || panRegion === 'horizontal') {
690
+ parent.img.destTop -= parent.panPoint.currentPannedPoint.y;
691
+ }
692
+ else {
693
+ parent.img.destTop += parent.panPoint.currentPannedPoint.y;
694
+ }
695
+ }
696
+ }
697
+ };
698
+ Crop.prototype.crop = function (obj) {
699
+ var _this = this;
700
+ var parent = this.parent;
701
+ if (!parent.disabled && parent.isImageLoaded) {
702
+ var object_1 = { isCropToolbar: parent.isCropToolbar };
703
+ if (parent.currObjType.isUndoAction && !object_1['isCropToolbar']) {
704
+ parent.notify('undo-redo', { prop: 'refreshUrc', value: { bool: null } });
705
+ }
706
+ var transitionArgs = { cancel: false, startPoint: { x: parent.activeObj.activePoint.startX,
707
+ y: parent.activeObj.activePoint.startY }, endPoint: { x: parent.activeObj.activePoint.endX,
708
+ y: parent.activeObj.activePoint.endY } };
709
+ if (!object_1['isCropToolbar'] && isBlazor() && parent.events && parent.events.cropping.hasDelegate === true) {
710
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
711
+ parent.dotNetRef.invokeMethodAsync('CropEventAsync', 'OnCrop', transitionArgs).then(function (args) {
712
+ _this.cropEvent(args, obj, object_1);
713
+ });
714
+ }
715
+ else {
716
+ if (!object_1['isCropToolbar']) {
717
+ parent.trigger('cropping', transitionArgs);
718
+ }
719
+ this.cropEvent(transitionArgs, obj, object_1);
720
+ }
721
+ }
722
+ };
723
+ Crop.prototype.cropEvent = function (transitionArgs, obj, object) {
724
+ var parent = this.parent;
725
+ var splitWords;
726
+ if (!transitionArgs.cancel) {
727
+ splitWords = parent.activeObj.shape ? parent.activeObj.shape.split('-') : [];
728
+ if (!parent.disabled && parent.activeObj.horTopLine && (parent.currObjType.isCustomCrop || (splitWords.length > 0 &&
729
+ splitWords[0] === 'crop'))) {
730
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
731
+ obj.isCrop = true;
732
+ var prevCropObj = extend({}, parent.cropObj, {}, true);
733
+ var prevObj = extend({}, this.prevCropCurrObj, {}, true);
734
+ this.cropImg();
735
+ parent.transform.zoomFactor = 0;
736
+ parent.zoomSettings.zoomFactor = 1;
737
+ parent.setProperties({ zoomSettings: { zoomFactor: 1 } }, true);
738
+ parent.notify('transform', { prop: 'setPreviousZoomValue', onPropertyChange: false,
739
+ value: { previousZoomValue: parent.zoomSettings.zoomFactor } });
740
+ var currSelPtObj = { prevCurrSelectionPoint: this.parent.prevCurrSelectionPoint };
741
+ prevObj.currSelectionPoint = extend({}, currSelPtObj['prevCurrSelectionPoint'], {}, true);
742
+ parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
743
+ value: { operation: 'crop', previousObj: prevObj, previousObjColl: prevObj.objColl,
744
+ previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
745
+ previousCropObj: prevCropObj, previousText: null,
746
+ currentText: null, previousFilter: null, isCircleCrop: parent.isCircleCrop } });
747
+ if (!object['isCropToolbar']) {
748
+ parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
749
+ }
750
+ parent.notify('transform', { prop: 'setCropDimension', onPropertyChange: false,
751
+ value: { width: parent.cropObj.destPoints.width, height: parent.cropObj.destPoints.height } });
752
+ if (!isBlazor() && !object['isCropToolbar']) {
753
+ parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
754
+ isApplyBtn: false, isCropping: false, isZooming: null, cType: null } });
755
+ }
756
+ else if (!object['isCropToolbar']) {
757
+ this.parent.updateToolbar(this.parent.element, 'imageLoaded');
758
+ }
759
+ }
760
+ }
761
+ };
762
+ Crop.prototype.calcRatio = function (obj) {
763
+ var parent = this.parent;
764
+ var widthRatio;
765
+ var heightRatio;
766
+ if (parent.transform.degree === 0 || parent.transform.degree % 180 === 0) {
767
+ widthRatio = parent.baseImg.width / parent.img.destWidth;
768
+ heightRatio = parent.baseImg.height / parent.img.destHeight;
769
+ }
770
+ else {
771
+ widthRatio = parent.baseImg.height / parent.img.destWidth;
772
+ heightRatio = parent.baseImg.width / parent.img.destHeight;
773
+ }
774
+ if (obj) {
775
+ obj['width'] = widthRatio;
776
+ obj['height'] = heightRatio;
777
+ }
778
+ return { width: widthRatio, height: heightRatio };
779
+ };
780
+ Crop.prototype.isObjInImage = function (obj, dummyObj) {
781
+ var parent = this.parent;
782
+ var isInside = false;
783
+ var startX = obj.activePoint.startX;
784
+ var endX = obj.activePoint.endX;
785
+ var startY = obj.activePoint.startY;
786
+ var endY = obj.activePoint.endY;
787
+ if ((startX >= parent.img.destLeft && endX <= (parent.img.destLeft + parent.img.destWidth)) ||
788
+ (startX <= parent.img.destLeft && endX >= parent.img.destLeft) ||
789
+ (startX <= (parent.img.destLeft + parent.img.destWidth) && endX >= (parent.img.destLeft + parent.img.destWidth)) ||
790
+ (startY >= parent.img.destTop && endY <= (parent.img.destTop + parent.img.destHeight)) ||
791
+ (startY <= parent.img.destTop && endY >= parent.img.destTop) ||
792
+ (startY <= (parent.img.destTop + parent.img.destHeight) && endY >= (parent.img.destTop + parent.img.destHeight))) {
793
+ isInside = true;
794
+ }
795
+ if (dummyObj) {
796
+ dummyObj['isInside'] = isInside;
797
+ }
798
+ return isInside;
799
+ };
800
+ Crop.prototype.getCurrFlipState = function (panObj) {
801
+ var parent = this.parent;
802
+ var obj = { panRegion: '' };
803
+ var object = { collection: parent.rotateFlipColl };
804
+ parent.notify('shape', { prop: 'alignRotateFlipColl', onPropertyChange: false,
805
+ value: { collection: parent.rotateFlipColl, isRotateFlipCollection: true, obj: object } });
806
+ parent.rotateFlipColl = object['collection'];
807
+ for (var i = 0, len = parent.rotateFlipColl.length; i < len; i++) {
808
+ parent.notify('transform', { prop: 'setCurrPanRegion', onPropertyChange: false,
809
+ value: { region: obj['panRegion'], type: parent.rotateFlipColl[i], obj: obj } });
810
+ }
811
+ if (panObj) {
812
+ panObj['panRegion'] = obj['panRegion'];
813
+ }
814
+ return obj['panRegion'];
815
+ };
816
+ return Crop;
817
+ }());
818
+ export { Crop };