@syncfusion/ej2-image-editor 23.2.7 → 24.1.43
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 +6 -54
- package/dist/ej2-image-editor.umd.min.js +2 -2
- package/dist/ej2-image-editor.umd.min.js.map +1 -1
- package/dist/es6/ej2-image-editor.es2015.js +7227 -4367
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +7295 -4422
- package/dist/es6/ej2-image-editor.es5.js.map +1 -1
- package/dist/global/ej2-image-editor.min.js +2 -2
- package/dist/global/ej2-image-editor.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +12 -12
- package/src/image-editor/action/crop.d.ts +6 -0
- package/src/image-editor/action/crop.js +347 -188
- package/src/image-editor/action/draw.d.ts +35 -2
- package/src/image-editor/action/draw.js +1691 -890
- package/src/image-editor/action/export.js +90 -29
- package/src/image-editor/action/filter.d.ts +3 -1
- package/src/image-editor/action/filter.js +74 -94
- package/src/image-editor/action/freehand-draw.d.ts +4 -0
- package/src/image-editor/action/freehand-draw.js +248 -147
- package/src/image-editor/action/selection.d.ts +6 -1
- package/src/image-editor/action/selection.js +1133 -1091
- package/src/image-editor/action/shape.d.ts +7 -0
- package/src/image-editor/action/shape.js +923 -550
- package/src/image-editor/action/transform.d.ts +2 -0
- package/src/image-editor/action/transform.js +518 -346
- package/src/image-editor/action/undo-redo.d.ts +2 -0
- package/src/image-editor/action/undo-redo.js +137 -36
- package/src/image-editor/base/enum.d.ts +2 -1
- package/src/image-editor/base/enum.js +1 -0
- package/src/image-editor/base/image-editor-model.d.ts +37 -2
- package/src/image-editor/base/image-editor.d.ts +124 -3
- package/src/image-editor/base/image-editor.js +675 -172
- package/src/image-editor/base/interface.d.ts +69 -15
- package/src/image-editor/renderer/toolbar.d.ts +10 -0
- package/src/image-editor/renderer/toolbar.js +1415 -835
- package/styles/bootstrap-dark.css +113 -8
- package/styles/bootstrap.css +112 -7
- package/styles/bootstrap4.css +113 -8
- package/styles/bootstrap5-dark.css +113 -8
- package/styles/bootstrap5.css +113 -8
- package/styles/fabric-dark.css +114 -9
- package/styles/fabric.css +113 -8
- package/styles/fluent-dark.css +118 -9
- package/styles/fluent.css +118 -9
- package/styles/highcontrast-light.css +112 -7
- package/styles/highcontrast.css +116 -7
- package/styles/image-editor/_bootstrap-dark-definition.scss +3 -0
- package/styles/image-editor/_bootstrap-definition.scss +3 -0
- package/styles/image-editor/_bootstrap4-definition.scss +3 -0
- package/styles/image-editor/_bootstrap5-definition.scss +3 -0
- package/styles/image-editor/_fabric-dark-definition.scss +3 -0
- package/styles/image-editor/_fabric-definition.scss +3 -0
- package/styles/image-editor/_fluent-definition.scss +3 -0
- package/styles/image-editor/_fusionnew-definition.scss +3 -0
- package/styles/image-editor/_highcontrast-definition.scss +3 -0
- package/styles/image-editor/_highcontrast-light-definition.scss +3 -0
- package/styles/image-editor/_layout.scss +138 -4
- package/styles/image-editor/_material-dark-definition.scss +3 -0
- package/styles/image-editor/_material-definition.scss +3 -0
- package/styles/image-editor/_material3-definition.scss +3 -0
- package/styles/image-editor/_tailwind-definition.scss +3 -0
- package/styles/image-editor/_theme.scss +2 -4
- package/styles/image-editor/bootstrap-dark.css +113 -8
- package/styles/image-editor/bootstrap.css +112 -7
- package/styles/image-editor/bootstrap4.css +113 -8
- package/styles/image-editor/bootstrap5-dark.css +113 -8
- package/styles/image-editor/bootstrap5.css +113 -8
- package/styles/image-editor/fabric-dark.css +114 -9
- package/styles/image-editor/fabric.css +113 -8
- package/styles/image-editor/fluent-dark.css +118 -9
- package/styles/image-editor/fluent.css +118 -9
- package/styles/image-editor/highcontrast-light.css +112 -7
- package/styles/image-editor/highcontrast.css +116 -7
- package/styles/image-editor/icons/_bootstrap-dark.scss +60 -0
- package/styles/image-editor/icons/_bootstrap.scss +60 -0
- package/styles/image-editor/icons/_bootstrap4.scss +60 -0
- package/styles/image-editor/icons/_bootstrap5.scss +60 -0
- package/styles/image-editor/icons/_fabric-dark.scss +60 -0
- package/styles/image-editor/icons/_fabric.scss +60 -0
- package/styles/image-editor/icons/_fluent.scss +66 -0
- package/styles/image-editor/icons/_highcontrast-light.scss +60 -0
- package/styles/image-editor/icons/_highcontrast.scss +60 -0
- package/styles/image-editor/icons/_material-dark.scss +60 -0
- package/styles/image-editor/icons/_material.scss +60 -0
- package/styles/image-editor/icons/_material3.scss +60 -0
- package/styles/image-editor/icons/_tailwind.scss +60 -0
- package/styles/image-editor/material-dark.css +113 -8
- package/styles/image-editor/material.css +113 -8
- package/styles/image-editor/material3-dark.css +126 -9
- package/styles/image-editor/material3.css +126 -9
- package/styles/image-editor/tailwind-dark.css +114 -9
- package/styles/image-editor/tailwind.css +114 -9
- package/styles/material-dark.css +113 -8
- package/styles/material.css +113 -8
- package/styles/material3-dark.css +126 -9
- package/styles/material3.css +126 -9
- package/styles/tailwind-dark.css +114 -9
- package/styles/tailwind.css +114 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extend, isBlazor, isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
1
|
+
import { Browser, extend, isBlazor, isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
2
2
|
var Crop = /** @class */ (function () {
|
|
3
3
|
function Crop(parent) {
|
|
4
4
|
this.croppedDegree = 0; // Specifies the degree when crop is performed
|
|
@@ -6,6 +6,7 @@ var Crop = /** @class */ (function () {
|
|
|
6
6
|
this.tempFlipPanPoint = { x: 0, y: 0 };
|
|
7
7
|
this.isPreventScaling = false;
|
|
8
8
|
this.isInitCrop = false;
|
|
9
|
+
this.isTransformCrop = false;
|
|
9
10
|
this.parent = parent;
|
|
10
11
|
this.addEventListener();
|
|
11
12
|
}
|
|
@@ -50,6 +51,9 @@ var Crop = /** @class */ (function () {
|
|
|
50
51
|
case 'getCurrFlipState':
|
|
51
52
|
this.getCurrFlipState(args.value['panObj']);
|
|
52
53
|
break;
|
|
54
|
+
case 'getPreviousCropCurrentObj':
|
|
55
|
+
args.value['obj']['prevObj'] = this.prevCropCurrObj;
|
|
56
|
+
break;
|
|
53
57
|
case 'setPreviousCropCurrentObj':
|
|
54
58
|
this.prevCropCurrObj = args.value['obj'];
|
|
55
59
|
break;
|
|
@@ -71,6 +75,18 @@ var Crop = /** @class */ (function () {
|
|
|
71
75
|
case 'getPreventScaling':
|
|
72
76
|
args.value['obj']['bool'] = this.isPreventScaling;
|
|
73
77
|
break;
|
|
78
|
+
case 'adjustStraightenForShapes':
|
|
79
|
+
this.adjustStraightenForShapes(args.value['type'], args.value['isInitialRotated']);
|
|
80
|
+
break;
|
|
81
|
+
case 'resizeWrapper':
|
|
82
|
+
this.resizeWrapper();
|
|
83
|
+
break;
|
|
84
|
+
case 'setTransformCrop':
|
|
85
|
+
this.isTransformCrop = args.value['bool'];
|
|
86
|
+
break;
|
|
87
|
+
case 'setInitCrop':
|
|
88
|
+
this.isInitCrop = args.value['bool'];
|
|
89
|
+
break;
|
|
74
90
|
case 'reset':
|
|
75
91
|
this.reset();
|
|
76
92
|
break;
|
|
@@ -95,15 +111,18 @@ var Crop = /** @class */ (function () {
|
|
|
95
111
|
this.tempFlipPanPoint = { x: 0, y: 0 };
|
|
96
112
|
this.isPreventScaling = false;
|
|
97
113
|
this.isInitCrop = false;
|
|
114
|
+
this.isTransformCrop = false;
|
|
98
115
|
};
|
|
99
116
|
Crop.prototype.cropImg = function (isRotateCrop) {
|
|
100
117
|
var parent = this.parent;
|
|
101
118
|
var isNullCrop = isNullOrUndefined(isRotateCrop);
|
|
102
|
-
var resizeIcon =
|
|
119
|
+
var resizeIcon = parent.element.querySelector('#' + parent.element.id + '_nonaspectratio');
|
|
103
120
|
var actPoint = parent.activeObj.activePoint;
|
|
121
|
+
var img = parent.img;
|
|
104
122
|
var isRotated = false;
|
|
105
|
-
for (var i = 0
|
|
106
|
-
|
|
123
|
+
for (var i = 0, len = parent.rotateFlipColl.length; i < len; i++) {
|
|
124
|
+
var currentValue = parent.rotateFlipColl[i];
|
|
125
|
+
if (currentValue === 90 || currentValue === -90) {
|
|
107
126
|
isRotated = true;
|
|
108
127
|
}
|
|
109
128
|
}
|
|
@@ -113,57 +132,53 @@ var Crop = /** @class */ (function () {
|
|
|
113
132
|
}
|
|
114
133
|
if (isNullCrop && (parent.transform.degree !== 0) || isRotated) {
|
|
115
134
|
this.updateCropObj();
|
|
116
|
-
var point = { startX:
|
|
117
|
-
height: parent.img.destHeight };
|
|
135
|
+
var point = { startX: img.destLeft, startY: img.destTop, width: img.destWidth, height: img.destHeight };
|
|
118
136
|
parent.notify('transform', { prop: 'setCurrDestinationPoint', onPropertyChange: false, value: { point: point } });
|
|
119
137
|
this.rotateCrop();
|
|
120
138
|
}
|
|
121
139
|
else if (isNullCrop && parent.transform.currFlipState !== '') {
|
|
122
140
|
this.updateCropObj();
|
|
123
|
-
var point = { startX:
|
|
124
|
-
height: parent.img.destHeight };
|
|
141
|
+
var point = { startX: img.destLeft, startY: img.destTop, width: img.destWidth, height: img.destHeight };
|
|
125
142
|
parent.notify('transform', { prop: 'setCurrDestinationPoint', onPropertyChange: false, value: { point: point } });
|
|
126
143
|
this.flipCrop();
|
|
127
144
|
}
|
|
128
145
|
else {
|
|
146
|
+
this.adjustStraightenForShapes('initial', false);
|
|
129
147
|
parent.notify('draw', { prop: 'setTempZoomFactor', onPropertyChange: false, value: { tempZoomFactor: parent.transform.zoomFactor } });
|
|
130
148
|
var ratio = this.calcRatio();
|
|
131
149
|
if (isNullCrop || !isRotateCrop) { // isRotateCrop is NULL or False
|
|
132
150
|
this.updateCropObj();
|
|
133
151
|
parent.notify('draw', { prop: 'resetPanPoints', onPropertyChange: false });
|
|
134
152
|
parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
|
|
135
|
-
var point = { startX:
|
|
136
|
-
height: parent.img.destHeight };
|
|
153
|
+
var point = { startX: img.destLeft, startY: img.destTop, width: img.destWidth, height: img.destHeight };
|
|
137
154
|
parent.notify('transform', { prop: 'setCurrDestinationPoint', onPropertyChange: false, value: { point: point } });
|
|
138
155
|
parent.currSelectionPoint = extend({}, parent.activeObj, {}, true);
|
|
139
|
-
this.cropDestPoints = { startX:
|
|
140
|
-
height: parent.img.destHeight };
|
|
156
|
+
this.cropDestPoints = { startX: img.destLeft, startY: img.destTop, width: img.destWidth, height: img.destHeight };
|
|
141
157
|
}
|
|
142
158
|
var obj = { width: 0, height: 0 };
|
|
143
|
-
parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
|
|
144
|
-
value: { width: actPoint.width * ratio.width,
|
|
159
|
+
parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false, value: { width: actPoint.width * ratio.width,
|
|
145
160
|
height: actPoint.height * ratio.height, obj: obj, isImgShape: null } });
|
|
146
161
|
var maxDimension = obj;
|
|
147
162
|
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
148
163
|
this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
149
|
-
parent.img
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
parent.img.destWidth = maxDimension.width;
|
|
156
|
-
parent.img.destHeight = maxDimension.height;
|
|
164
|
+
parent.img = { srcLeft: (actPoint.startX * ratio.width) - (img.destLeft * ratio.width),
|
|
165
|
+
srcTop: (actPoint.startY * ratio.height) - (img.destTop * ratio.height),
|
|
166
|
+
srcWidth: (actPoint.width * ratio.width), srcHeight: (actPoint.height * ratio.height),
|
|
167
|
+
destLeft: (parent.lowerCanvas.clientWidth - maxDimension.width) / 2,
|
|
168
|
+
destTop: (parent.lowerCanvas.clientHeight - maxDimension.height + 1) / 2,
|
|
169
|
+
destWidth: maxDimension.width, destHeight: maxDimension.height };
|
|
157
170
|
var temp = this.lowerContext.filter;
|
|
158
171
|
parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
|
|
159
172
|
this.lowerContext.filter = 'none';
|
|
160
173
|
var activeObj = extend({}, parent.activeObj, {}, true);
|
|
161
174
|
this.cropObjColl();
|
|
175
|
+
parent.transform.straighten = 0;
|
|
162
176
|
parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
163
|
-
|
|
164
|
-
|
|
177
|
+
var objColl = extend([], parent.objColl, [], true);
|
|
178
|
+
for (var i = 0, len = objColl.length; i < len; i++) {
|
|
179
|
+
if (this.isObjInImage(objColl[i])) {
|
|
165
180
|
parent.notify('shape', { prop: 'apply', onPropertyChange: false,
|
|
166
|
-
value: { shape:
|
|
181
|
+
value: { shape: objColl[i].shape, obj: objColl[i], canvas: null } });
|
|
167
182
|
parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
|
|
168
183
|
}
|
|
169
184
|
}
|
|
@@ -172,7 +187,7 @@ var Crop = /** @class */ (function () {
|
|
|
172
187
|
parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
173
188
|
parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
|
|
174
189
|
parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
|
|
175
|
-
if (parent.currSelectionPoint
|
|
190
|
+
if (parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') {
|
|
176
191
|
this.cropCircle(this.lowerContext);
|
|
177
192
|
}
|
|
178
193
|
else {
|
|
@@ -185,15 +200,45 @@ var Crop = /** @class */ (function () {
|
|
|
185
200
|
parent.transform.defaultZoomFactor = 0;
|
|
186
201
|
}
|
|
187
202
|
};
|
|
203
|
+
Crop.prototype.adjustStraightenForShapes = function (type, isInitialRotated) {
|
|
204
|
+
var parent = this.parent;
|
|
205
|
+
var center = {
|
|
206
|
+
x: parent.img.destLeft + parent.img.destWidth / 2,
|
|
207
|
+
y: parent.img.destTop + parent.img.destHeight / 2
|
|
208
|
+
};
|
|
209
|
+
for (var _i = 0, _a = parent.objColl; _i < _a.length; _i++) {
|
|
210
|
+
var obj = _a[_i];
|
|
211
|
+
if (['rectangle', 'ellipse', 'text', 'image'].indexOf(obj.shape) !== -1) {
|
|
212
|
+
if (isInitialRotated || obj.rotatedAngle !== 0) {
|
|
213
|
+
var _b = obj.activePoint, startX = _b.startX, startY = _b.startY, width = _b.width, height = _b.height;
|
|
214
|
+
var angle = type === 'initial' ? obj.rotatedAngle : -obj.rotatedAngle;
|
|
215
|
+
var diffX = startX + width / 2 - center.x;
|
|
216
|
+
var diffY = startY + height / 2 - center.y;
|
|
217
|
+
var cosAngle = Math.cos(angle);
|
|
218
|
+
var sinAngle = Math.sin(angle);
|
|
219
|
+
var centerX = cosAngle * diffX - sinAngle * diffY + center.x;
|
|
220
|
+
var centerY = sinAngle * diffX + cosAngle * diffY + center.y;
|
|
221
|
+
var diffXUpdated = centerX - startX - width / 2;
|
|
222
|
+
var diffYUpdated = centerY - startY - height / 2;
|
|
223
|
+
obj.activePoint.startX += diffXUpdated;
|
|
224
|
+
obj.activePoint.startY += diffYUpdated;
|
|
225
|
+
obj.activePoint.endX += diffXUpdated;
|
|
226
|
+
obj.activePoint.endY += diffYUpdated;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
};
|
|
188
231
|
Crop.prototype.updateCropObj = function () {
|
|
189
232
|
this.parent.afterCropActions = [];
|
|
190
233
|
var object = { currObj: {} };
|
|
191
234
|
this.parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
192
235
|
var obj = object['currObj'];
|
|
236
|
+
obj.straighten = this.parent.transform.straighten;
|
|
193
237
|
this.parent.cropObj = extend({}, obj, {}, true);
|
|
194
238
|
};
|
|
195
239
|
Crop.prototype.rotateCrop = function () {
|
|
196
240
|
var parent = this.parent;
|
|
241
|
+
var flipState = this.getCurrFlipState();
|
|
197
242
|
var shape = parent.activeObj.shape || '';
|
|
198
243
|
parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
|
|
199
244
|
parent.currSelectionPoint = extend({}, parent.activeObj, {}, true);
|
|
@@ -206,14 +251,54 @@ var Crop = /** @class */ (function () {
|
|
|
206
251
|
parent.notify('transform', { prop: 'setPreventSelect', onPropertyChange: false, value: { bool: true } });
|
|
207
252
|
var coll = extend([], parent.rotateFlipColl, [], true);
|
|
208
253
|
this.panToSelRangle(true);
|
|
254
|
+
activeObj = extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
|
|
255
|
+
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
256
|
+
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: activeObj } });
|
|
257
|
+
parent.objColl.pop();
|
|
258
|
+
parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
|
|
259
|
+
parent.objColl.push(parent.activeObj);
|
|
260
|
+
// For reverse straightening
|
|
261
|
+
var straighten = parent.transform.straighten;
|
|
262
|
+
if (straighten !== 0) {
|
|
263
|
+
parent.transform.straighten = 0;
|
|
264
|
+
parent.straightenBaseImageCanvas();
|
|
265
|
+
parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
266
|
+
parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
267
|
+
parent.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
|
|
268
|
+
}
|
|
209
269
|
this.resetZoom();
|
|
210
270
|
var afterCropActions = extend([], parent.afterCropActions, [], true);
|
|
211
271
|
this.revertTransform('initial', coll);
|
|
272
|
+
// Perform straighten
|
|
273
|
+
if (straighten !== 0) {
|
|
274
|
+
parent.transform.straighten = (flipState === 'horizontal' || flipState === 'vertical') ? -straighten : straighten;
|
|
275
|
+
parent.straightenBaseImageCanvas();
|
|
276
|
+
parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
277
|
+
parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
278
|
+
parent.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
|
|
279
|
+
parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
280
|
+
parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
281
|
+
}
|
|
212
282
|
activeObj = extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
|
|
213
283
|
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
214
284
|
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: activeObj } });
|
|
215
285
|
parent.objColl.pop();
|
|
216
286
|
parent.transform.degree = 0;
|
|
287
|
+
// Checking for selection inside image
|
|
288
|
+
var object = { isIntersect: null };
|
|
289
|
+
parent.notify('draw', { prop: 'updateImgCanvasPoints', onPropertyChange: false });
|
|
290
|
+
parent.notify('draw', { prop: 'isLinesIntersect', onPropertyChange: false, value: { obj: object } });
|
|
291
|
+
var count = 0;
|
|
292
|
+
while (straighten !== 0 && object['isIntersect']) {
|
|
293
|
+
count++;
|
|
294
|
+
if (count === 50) {
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
298
|
+
value: { zoomFactor: 0.025, zoomPoint: null }, isResize: null });
|
|
299
|
+
parent.notify('draw', { prop: 'updateImgCanvasPoints', onPropertyChange: false });
|
|
300
|
+
parent.notify('draw', { prop: 'isLinesIntersect', onPropertyChange: false, value: { obj: object } });
|
|
301
|
+
}
|
|
217
302
|
this.cropImg(true);
|
|
218
303
|
this.revertTransform('reverse', coll);
|
|
219
304
|
parent.afterCropActions = afterCropActions;
|
|
@@ -232,7 +317,8 @@ var Crop = /** @class */ (function () {
|
|
|
232
317
|
var obj = { isRotate: false };
|
|
233
318
|
if (type === 'initial') {
|
|
234
319
|
for (var i = coll.length - 1; i >= 0; i--) {
|
|
235
|
-
|
|
320
|
+
var value = coll[i];
|
|
321
|
+
switch (value) {
|
|
236
322
|
case 90:
|
|
237
323
|
parent.notify('transform', { prop: 'rotate', value: { degree: -90, obj: obj } });
|
|
238
324
|
break;
|
|
@@ -240,20 +326,16 @@ var Crop = /** @class */ (function () {
|
|
|
240
326
|
parent.notify('transform', { prop: 'rotate', value: { degree: 90, obj: obj } });
|
|
241
327
|
break;
|
|
242
328
|
default:
|
|
243
|
-
parent.notify('transform', { prop: 'flipImage', value: { direction: parent.toPascalCase(
|
|
329
|
+
parent.notify('transform', { prop: 'flipImage', value: { direction: parent.toPascalCase(value.toString()) } });
|
|
244
330
|
break;
|
|
245
331
|
}
|
|
246
332
|
}
|
|
247
333
|
}
|
|
248
334
|
else {
|
|
249
|
-
|
|
250
|
-
parent.objColl[i].shapeFlip = '';
|
|
251
|
-
}
|
|
252
|
-
for (var i = 0; i < parent.freehandCounter; i++) {
|
|
253
|
-
parent.pointColl[i].shapeFlip = '';
|
|
254
|
-
}
|
|
335
|
+
this.updateFlipState();
|
|
255
336
|
for (var i = 0, len = coll.length; i < len; i++) {
|
|
256
|
-
|
|
337
|
+
var value = coll[i];
|
|
338
|
+
switch (value) {
|
|
257
339
|
case 90:
|
|
258
340
|
parent.notify('transform', { prop: 'rotate', value: { degree: 90, obj: obj } });
|
|
259
341
|
break;
|
|
@@ -261,17 +343,32 @@ var Crop = /** @class */ (function () {
|
|
|
261
343
|
parent.notify('transform', { prop: 'rotate', value: { degree: -90, obj: obj } });
|
|
262
344
|
break;
|
|
263
345
|
default:
|
|
264
|
-
parent.notify('transform', { prop: 'flipImage', value: { direction: parent.toPascalCase(
|
|
346
|
+
parent.notify('transform', { prop: 'flipImage', value: { direction: parent.toPascalCase(value.toString()) } });
|
|
265
347
|
break;
|
|
266
348
|
}
|
|
267
349
|
}
|
|
268
350
|
}
|
|
269
351
|
};
|
|
352
|
+
Crop.prototype.updateFlipState = function () {
|
|
353
|
+
var parent = this.parent;
|
|
354
|
+
var objColl = parent.objColl;
|
|
355
|
+
for (var i = 0, len = objColl.length; i < len; i++) {
|
|
356
|
+
objColl[i].shapeFlip = '';
|
|
357
|
+
}
|
|
358
|
+
// eslint-disable-next-line
|
|
359
|
+
var pointColl = parent.pointColl;
|
|
360
|
+
for (var i = 0; i < parent.freehandCounter; i++) {
|
|
361
|
+
pointColl[i].shapeFlip = '';
|
|
362
|
+
}
|
|
363
|
+
};
|
|
270
364
|
Crop.prototype.resetZoom = function () {
|
|
271
365
|
var parent = this.parent;
|
|
272
366
|
if (parent.transform.zoomFactor > 0) {
|
|
273
367
|
var zoomFactor = parent.transform.zoomFactor;
|
|
274
368
|
var isUndoRedo = parent.isUndoRedo;
|
|
369
|
+
parent.setProperties({ zoomSettings: { zoomFactor: (zoomFactor * 10) } }, true);
|
|
370
|
+
parent.notify('transform', { prop: 'setPreviousZoomValue', onPropertyChange: false,
|
|
371
|
+
value: { previousZoomValue: parent.zoomSettings.zoomFactor } });
|
|
275
372
|
for (var i = 0; i < (zoomFactor * 10); i++) {
|
|
276
373
|
parent.isUndoRedo = true;
|
|
277
374
|
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
@@ -293,18 +390,26 @@ var Crop = /** @class */ (function () {
|
|
|
293
390
|
parent.notify('transform', { prop: 'setFlipColl', onPropertyChange: false, value: { flipColl: [] } });
|
|
294
391
|
parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
|
|
295
392
|
parent.objColl.push(parent.activeObj);
|
|
393
|
+
if (parent.transform.degree === 0) {
|
|
394
|
+
var panX = -parent.cropObj.totalPannedPoint.x;
|
|
395
|
+
var panY = -parent.cropObj.totalPannedPoint.y;
|
|
396
|
+
parent.img.destLeft += panX;
|
|
397
|
+
parent.img.destTop += panY;
|
|
398
|
+
parent.notify('transform', { prop: 'drawPannImage', value: { point: { x: panX, y: panY } } });
|
|
399
|
+
parent.activeObj = extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
|
|
400
|
+
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
401
|
+
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj } });
|
|
402
|
+
parent.objColl.pop();
|
|
403
|
+
parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
|
|
404
|
+
parent.objColl.push(parent.activeObj);
|
|
405
|
+
}
|
|
296
406
|
this.resetZoom();
|
|
297
407
|
parent.currSelectionPoint = extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
|
|
298
408
|
this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
299
409
|
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
300
410
|
var temp = this.lowerContext.filter;
|
|
301
411
|
parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
|
|
302
|
-
|
|
303
|
-
parent.objColl[i].shapeFlip = '';
|
|
304
|
-
}
|
|
305
|
-
for (var i = 0; i < parent.freehandCounter; i++) {
|
|
306
|
-
parent.pointColl[i].shapeFlip = '';
|
|
307
|
-
}
|
|
412
|
+
this.updateFlipState();
|
|
308
413
|
parent.notify('shape', { prop: 'redrawObj', onPropertyChange: false, value: { degree: this.getCurrFlipState() } });
|
|
309
414
|
parent.notify('freehand-draw', { prop: 'flipFHDColl', onPropertyChange: false,
|
|
310
415
|
value: { value: this.getCurrFlipState() } });
|
|
@@ -326,12 +431,7 @@ var Crop = /** @class */ (function () {
|
|
|
326
431
|
parent.transform.currFlipState = tempCurrFlipState;
|
|
327
432
|
parent.notify('transform', { prop: 'setFlipColl', onPropertyChange: false, value: { flipColl: tempFlipColl } });
|
|
328
433
|
this.lowerContext.filter = 'none';
|
|
329
|
-
|
|
330
|
-
parent.objColl[i].shapeFlip = '';
|
|
331
|
-
}
|
|
332
|
-
for (var i = 0; i < parent.freehandCounter; i++) {
|
|
333
|
-
parent.pointColl[i].shapeFlip = '';
|
|
334
|
-
}
|
|
434
|
+
this.updateFlipState();
|
|
335
435
|
parent.notify('shape', { prop: 'redrawObj', onPropertyChange: false, value: { degree: this.getCurrFlipState() } });
|
|
336
436
|
parent.notify('freehand-draw', { prop: 'flipFHDColl', onPropertyChange: false,
|
|
337
437
|
value: { value: this.getCurrFlipState() } });
|
|
@@ -352,37 +452,31 @@ var Crop = /** @class */ (function () {
|
|
|
352
452
|
Crop.prototype.cropObjColl = function () {
|
|
353
453
|
var parent = this.parent;
|
|
354
454
|
var point;
|
|
355
|
-
var activePoint;
|
|
356
455
|
var shape;
|
|
456
|
+
var obj;
|
|
357
457
|
if (parent.objColl.length > 0) {
|
|
358
458
|
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
endY: ((point.endY -
|
|
366
|
-
width:
|
|
367
|
-
height: activePoint.height / point.height };
|
|
459
|
+
obj = parent.objColl[i];
|
|
460
|
+
point = obj.activePoint;
|
|
461
|
+
var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
|
|
462
|
+
shape = obj.shape;
|
|
463
|
+
obj.imageRatio = { startX: ((point.startX - startX) / width),
|
|
464
|
+
startY: ((point.startY - startY) / height),
|
|
465
|
+
endX: ((point.endX - startX) / width), endY: ((point.endY - startY) / height),
|
|
466
|
+
width: width / point.width, height: height / point.height };
|
|
368
467
|
var degree = void 0;
|
|
369
468
|
var size = void 0;
|
|
370
469
|
switch (shape) {
|
|
371
470
|
case 'text':
|
|
372
|
-
|
|
373
|
-
degree = this.parent.transform.degree;
|
|
374
|
-
}
|
|
375
|
-
else {
|
|
376
|
-
degree = this.parent.transform.degree - parent.objColl[i].shapeDegree;
|
|
377
|
-
}
|
|
471
|
+
degree = (obj.shapeDegree === 0) ? parent.transform.degree : parent.transform.degree - obj.shapeDegree;
|
|
378
472
|
size = (degree === 0 || Math.abs(degree) === 180) ? point.width : point.height;
|
|
379
|
-
|
|
473
|
+
obj.textSettings.fontRatio = size / obj.textSettings.fontSize;
|
|
380
474
|
break;
|
|
381
475
|
case 'line':
|
|
382
476
|
case 'arrow':
|
|
383
477
|
this.cropPointCollection(i);
|
|
384
478
|
if (shape === 'arrow') {
|
|
385
|
-
parent.notify('shape', { prop: 'updateArrowRatio', onPropertyChange: false, value: { obj:
|
|
479
|
+
parent.notify('shape', { prop: 'updateArrowRatio', onPropertyChange: false, value: { obj: obj } });
|
|
386
480
|
}
|
|
387
481
|
break;
|
|
388
482
|
case 'path':
|
|
@@ -400,6 +494,7 @@ var Crop = /** @class */ (function () {
|
|
|
400
494
|
var width;
|
|
401
495
|
var height;
|
|
402
496
|
var point = parent.activeObj.activePoint;
|
|
497
|
+
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
403
498
|
if (shape === 'path') {
|
|
404
499
|
x = point.startX;
|
|
405
500
|
y = point.startY;
|
|
@@ -407,64 +502,64 @@ var Crop = /** @class */ (function () {
|
|
|
407
502
|
height = point.height;
|
|
408
503
|
}
|
|
409
504
|
else {
|
|
410
|
-
x =
|
|
411
|
-
y =
|
|
412
|
-
width =
|
|
413
|
-
height =
|
|
505
|
+
x = destLeft;
|
|
506
|
+
y = destTop;
|
|
507
|
+
width = destWidth;
|
|
508
|
+
height = destHeight;
|
|
414
509
|
}
|
|
415
|
-
var
|
|
416
|
-
for (var n = 0, len =
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
selPoint.pointColl[n].ratioY =
|
|
420
|
-
(selPoint.pointColl[n].y - y) / height;
|
|
510
|
+
var pointColl = parent.objColl[i].pointColl;
|
|
511
|
+
for (var n = 0, len = pointColl.length; n < len; n++) {
|
|
512
|
+
pointColl[n].ratioX = (pointColl[n].x - x) / width;
|
|
513
|
+
pointColl[n].ratioY = (pointColl[n].y - y) / height;
|
|
421
514
|
}
|
|
422
515
|
};
|
|
423
516
|
Crop.prototype.cropFreehandDrawColl = function () {
|
|
424
517
|
var parent = this.parent;
|
|
425
|
-
|
|
518
|
+
var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
|
|
426
519
|
for (var n = 0; n < parent.freehandCounter; n++) {
|
|
427
520
|
parent.points = extend([], parent.pointColl[n].points, []);
|
|
428
521
|
parent.notify('freehand-draw', { prop: 'setPointCounter', onPropertyChange: false, value: { value: 0 } });
|
|
429
522
|
var len = parent.points.length;
|
|
430
523
|
for (var l = 0; l < len; l++) {
|
|
431
|
-
parent.points[l].ratioX = (parent.points[l].x -
|
|
432
|
-
|
|
433
|
-
parent.points[l].ratioY = (parent.points[l].y -
|
|
434
|
-
parent.activeObj.activePoint.startY) / parent.activeObj.activePoint.height;
|
|
524
|
+
parent.points[l].ratioX = (parent.points[l].x - startX) / width;
|
|
525
|
+
parent.points[l].ratioY = (parent.points[l].y - startY) / height;
|
|
435
526
|
}
|
|
436
527
|
}
|
|
437
528
|
parent.notify('freehand-draw', { prop: 'updateCropPtsForSel', onPropertyChange: false });
|
|
438
529
|
};
|
|
530
|
+
Crop.prototype.resetAnnotations = function () {
|
|
531
|
+
var parent = this.parent;
|
|
532
|
+
parent.objColl = [];
|
|
533
|
+
parent.pointColl = [];
|
|
534
|
+
parent.freehandCounter = 0;
|
|
535
|
+
parent.notify('freehand-draw', { prop: 'resetStraightenPoint' });
|
|
536
|
+
};
|
|
439
537
|
Crop.prototype.setCurrSelPoints = function (isSetDimension) {
|
|
440
538
|
var parent = this.parent;
|
|
441
539
|
parent.allowDownScale = false;
|
|
442
540
|
var destPoint = this.cropDestPoints;
|
|
443
541
|
var filter = this.lowerContext.filter;
|
|
444
|
-
|
|
445
|
-
parent.img
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
parent.img.destTop = destPoint.startY;
|
|
450
|
-
parent.img.destWidth = destPoint.width;
|
|
451
|
-
parent.img.destHeight = destPoint.height;
|
|
542
|
+
var isCropTab = parent.isCropTab;
|
|
543
|
+
parent.img = { srcLeft: 0, srcTop: 0, srcWidth: parent.baseImgCanvas.width, srcHeight: parent.baseImgCanvas.height,
|
|
544
|
+
destLeft: destPoint.startX, destTop: destPoint.startY, destWidth: destPoint.width, destHeight: destPoint.height };
|
|
545
|
+
var img = parent.img;
|
|
546
|
+
var currSelPoint = parent.currSelectionPoint;
|
|
452
547
|
this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
453
548
|
if (isSetDimension) {
|
|
454
549
|
parent.notify('draw', { prop: 'setDestPoints', onPropertyChange: false });
|
|
455
550
|
}
|
|
456
551
|
parent.notify('draw', { prop: 'currTransState', onPropertyChange: false,
|
|
457
552
|
value: { type: 'initial', isPreventDestination: null, context: null, isPreventCircleCrop: null } });
|
|
458
|
-
if (this.croppedDegree === 0 && parent.transform.degree === 0 &&
|
|
459
|
-
&&
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
553
|
+
if (this.croppedDegree === 0 && parent.transform.degree === 0 && currSelPoint
|
|
554
|
+
&& currSelPoint.shape !== 'crop-circle' && currSelPoint.shape !== 'crop-square') {
|
|
555
|
+
img.destLeft = destPoint.startX;
|
|
556
|
+
img.destTop = destPoint.startY;
|
|
557
|
+
img.destWidth = destPoint.width;
|
|
558
|
+
img.destHeight = destPoint.height;
|
|
464
559
|
}
|
|
465
560
|
if (parent.transform.degree === 0) {
|
|
466
|
-
|
|
467
|
-
|
|
561
|
+
img.destLeft += parent.panPoint.totalPannedInternalPoint.x;
|
|
562
|
+
img.destTop += parent.panPoint.totalPannedInternalPoint.y;
|
|
468
563
|
}
|
|
469
564
|
parent.notify('draw', { prop: 'drawImage', onPropertyChange: false });
|
|
470
565
|
this.lowerContext.filter = filter;
|
|
@@ -472,40 +567,47 @@ var Crop = /** @class */ (function () {
|
|
|
472
567
|
value: { type: 'reverse', isPreventDestination: null, context: null, isPreventCircleCrop: true } });
|
|
473
568
|
var cropObjColl = extend([], parent.objColl, null, true);
|
|
474
569
|
var cropPointColl = extend([], parent.pointColl, null, true);
|
|
475
|
-
|
|
476
|
-
parent.
|
|
477
|
-
|
|
570
|
+
var straightenObj = { straightenPoint: null };
|
|
571
|
+
parent.notify('freehand-draw', { prop: 'getStraightenPoint', onPropertyChange: false,
|
|
572
|
+
value: { obj: straightenObj } });
|
|
573
|
+
this.resetAnnotations();
|
|
574
|
+
if (isNullOrUndefined(parent.activeObj.shape) && parent.cropObj.activeObj.shape) {
|
|
575
|
+
parent.activeObj = extend({}, parent.cropObj.activeObj, null, true);
|
|
576
|
+
}
|
|
478
577
|
this.panToSelRangle();
|
|
578
|
+
parent.isCropTab = isCropTab;
|
|
479
579
|
parent.objColl = cropObjColl;
|
|
480
580
|
parent.pointColl = cropPointColl;
|
|
481
581
|
parent.freehandCounter = parent.pointColl.length;
|
|
582
|
+
if (straightenObj['straightenPoint']['x'] && straightenObj['straightenPoint']['y']) {
|
|
583
|
+
parent.notify('freehand-draw', { prop: 'setStraightenPoint', onPropertyChange: false,
|
|
584
|
+
value: { x: straightenObj['straightenPoint']['x'], y: straightenObj['straightenPoint']['y'],
|
|
585
|
+
ratioX: straightenObj['straightenPoint']['ratioX'], ratioY: straightenObj['straightenPoint']['ratioY'] } });
|
|
586
|
+
}
|
|
482
587
|
if (parent.cropObj.activeObj.shape) {
|
|
483
|
-
var destPoints = { startX:
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
588
|
+
var destPoints = { startX: img.destLeft, startY: img.destTop, width: img.destWidth, height: img.destHeight };
|
|
589
|
+
if (currSelPoint && currSelPoint.activePoint) {
|
|
590
|
+
var _a = currSelPoint.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
|
|
591
|
+
img.destLeft = startX;
|
|
592
|
+
img.destTop = startY;
|
|
593
|
+
img.destWidth = width;
|
|
594
|
+
img.destHeight = height;
|
|
490
595
|
}
|
|
491
596
|
parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
492
597
|
parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
598
|
+
img.destLeft = destPoints.startX;
|
|
599
|
+
img.destTop = destPoints.startY;
|
|
600
|
+
img.destWidth = destPoints.width;
|
|
601
|
+
img.destHeight = destPoints.height;
|
|
497
602
|
parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false });
|
|
498
603
|
cropObjColl = extend([], parent.objColl, null, true);
|
|
499
604
|
cropPointColl = extend([], parent.pointColl, null, true);
|
|
500
|
-
parent.
|
|
501
|
-
|
|
502
|
-
parent.freehandCounter = 0;
|
|
605
|
+
parent.notify('freehand-draw', { prop: 'getStraightenPoint', onPropertyChange: false, value: { obj: straightenObj } });
|
|
606
|
+
this.resetAnnotations();
|
|
503
607
|
var object = { selPointColl: null };
|
|
504
|
-
parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
505
|
-
value: { obj: object } });
|
|
608
|
+
parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false, value: { obj: object } });
|
|
506
609
|
var cropSelPointColl = object['selPointColl'];
|
|
507
|
-
parent.notify('freehand-draw', { prop: 'setSelPointColl', onPropertyChange: false,
|
|
508
|
-
value: { obj: { selPointColl: [] } } });
|
|
610
|
+
parent.notify('freehand-draw', { prop: 'setSelPointColl', onPropertyChange: false, value: { obj: { selPointColl: [] } } });
|
|
509
611
|
parent.cropObj.filter = this.lowerContext.filter;
|
|
510
612
|
var actObj = extend({}, parent.currSelectionPoint, null, true);
|
|
511
613
|
parent.notify('draw', { prop: 'setCurrentObj', onPropertyChange: false, value: { obj: null } });
|
|
@@ -515,24 +617,40 @@ var Crop = /** @class */ (function () {
|
|
|
515
617
|
parent.currSelectionPoint = null;
|
|
516
618
|
parent.isCircleCrop = false;
|
|
517
619
|
if (parent.transform.degree !== 0) {
|
|
620
|
+
if (isNullOrUndefined(parent.activeObj.shape) && parent.cropObj.activeObj.shape) {
|
|
621
|
+
parent.activeObj = extend({}, parent.cropObj.activeObj, null, true);
|
|
622
|
+
}
|
|
518
623
|
parent.notify('transform', { prop: 'drawPannedImage', value: { xDiff: 0, yDiff: 0 } });
|
|
519
624
|
parent.panPoint.currentPannedPoint = { x: 0, y: 0 };
|
|
520
625
|
}
|
|
521
626
|
parent.objColl = cropObjColl;
|
|
522
627
|
parent.pointColl = cropPointColl;
|
|
523
628
|
parent.freehandCounter = parent.pointColl.length;
|
|
629
|
+
if (straightenObj['straightenPoint']['x'] && straightenObj['straightenPoint']['y']) {
|
|
630
|
+
parent.notify('freehand-draw', { prop: 'setStraightenPoint', onPropertyChange: false,
|
|
631
|
+
value: { x: straightenObj['straightenPoint']['x'], y: straightenObj['straightenPoint']['y'],
|
|
632
|
+
ratioX: straightenObj['straightenPoint']['ratioX'], ratioY: straightenObj['straightenPoint']['ratioY'] } });
|
|
633
|
+
}
|
|
524
634
|
parent.notify('freehand-draw', { prop: 'setSelPointColl', onPropertyChange: false,
|
|
525
635
|
value: { obj: { selPointColl: cropSelPointColl } } });
|
|
526
636
|
parent.notify('shape', { prop: 'iterateObjColl', onPropertyChange: false });
|
|
527
637
|
parent.notify('freehand-draw', { prop: 'freehandRedraw', onPropertyChange: false,
|
|
528
638
|
value: { context: this.lowerContext, points: null } });
|
|
529
|
-
|
|
639
|
+
this.adjustStraightenForShapes('reverse', false);
|
|
640
|
+
parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false, value: { isPreventApply: true } });
|
|
530
641
|
parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
531
642
|
parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
|
|
532
643
|
if (parent.transform.degree === 0) {
|
|
533
644
|
parent.notify('transform', { prop: 'drawPannImage', onPropertyChange: false,
|
|
534
645
|
value: { point: { x: 0, y: 0 } } });
|
|
535
646
|
}
|
|
647
|
+
else {
|
|
648
|
+
if (isNullOrUndefined(parent.activeObj.shape) && parent.cropObj.activeObj.shape) {
|
|
649
|
+
parent.activeObj = extend({}, parent.cropObj.activeObj, null, true);
|
|
650
|
+
}
|
|
651
|
+
parent.notify('transform', { prop: 'drawPannedImage', value: { xDiff: 0, yDiff: 0 } });
|
|
652
|
+
parent.panPoint.currentPannedPoint = { x: 0, y: 0 };
|
|
653
|
+
}
|
|
536
654
|
parent.activeObj = activeObj;
|
|
537
655
|
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
|
|
538
656
|
parent.notify('transform', { prop: 'setTempPanMove', onPropertyChange: false,
|
|
@@ -540,7 +658,10 @@ var Crop = /** @class */ (function () {
|
|
|
540
658
|
if (!this.isInitCrop && parent.transform.degree === 0 && parent.cropObj.currFlipState !== '' &&
|
|
541
659
|
parent.cropObj.cropZoom !== 0) {
|
|
542
660
|
this.isInitCrop = true;
|
|
661
|
+
var obj = { activeObj: null };
|
|
662
|
+
parent.notify('draw', { prop: 'getStraightenActObj', onPropertyChange: false, value: { obj: obj } });
|
|
543
663
|
parent.notify('draw', { prop: 'performCancel', value: { isContextualToolbar: null } });
|
|
664
|
+
parent.notify('draw', { prop: 'setStraightenActObj', onPropertyChange: false, value: { activeObj: obj['activeObj'] } });
|
|
544
665
|
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'croptransform',
|
|
545
666
|
isApplyBtn: false, isCropping: null, isZooming: null, cType: null } });
|
|
546
667
|
}
|
|
@@ -549,6 +670,8 @@ var Crop = /** @class */ (function () {
|
|
|
549
670
|
}
|
|
550
671
|
}
|
|
551
672
|
else {
|
|
673
|
+
this.adjustStraightenForShapes('reverse', true);
|
|
674
|
+
parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false, value: { isPreventApply: true } });
|
|
552
675
|
var temp = this.lowerContext.filter;
|
|
553
676
|
this.lowerContext.filter = 'none';
|
|
554
677
|
parent.notify('shape', { prop: 'iterateObjColl', onPropertyChange: false });
|
|
@@ -557,13 +680,15 @@ var Crop = /** @class */ (function () {
|
|
|
557
680
|
this.lowerContext.filter = temp;
|
|
558
681
|
parent.currSelectionPoint = null;
|
|
559
682
|
}
|
|
683
|
+
if (document.querySelector('.e-ie-straighten-value-span')) {
|
|
684
|
+
document.querySelector('.e-ie-straighten-value-span').innerHTML = parent.transform.straighten.toString() + '°';
|
|
685
|
+
}
|
|
560
686
|
};
|
|
561
687
|
Crop.prototype.panToSelRangle = function (isReverse) {
|
|
562
688
|
var parent = this.parent;
|
|
563
|
-
var
|
|
564
|
-
|
|
565
|
-
var panY = parent.transform.degree !== 0 ?
|
|
566
|
-
isReverse ? -parent.cropObj.totalPannedClientPoint.y : parent.cropObj.totalPannedClientPoint.y : 0;
|
|
689
|
+
var pannedPoint = parent.cropObj.totalPannedClientPoint;
|
|
690
|
+
var panX = parent.transform.degree !== 0 ? isReverse ? -pannedPoint.x : pannedPoint.x : 0;
|
|
691
|
+
var panY = parent.transform.degree !== 0 ? isReverse ? -pannedPoint.y : pannedPoint.y : 0;
|
|
567
692
|
if (parent.transform.degree !== 0) {
|
|
568
693
|
parent.panPoint.currentPannedPoint = { x: panX, y: panY };
|
|
569
694
|
parent.notify('transform', { prop: 'drawPannedImage', value: { xDiff: panX, yDiff: panY } });
|
|
@@ -572,6 +697,7 @@ var Crop = /** @class */ (function () {
|
|
|
572
697
|
};
|
|
573
698
|
Crop.prototype.cropCircle = function (context, isSave, isFlip) {
|
|
574
699
|
var parent = this.parent;
|
|
700
|
+
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
575
701
|
if (isFlip && parent.transform.currFlipState !== '') {
|
|
576
702
|
parent.notify('draw', { prop: 'setTransform', onPropertyChange: false,
|
|
577
703
|
value: { context: context, value: parent.transform.currFlipState, isReverse: null } });
|
|
@@ -580,9 +706,9 @@ var Crop = /** @class */ (function () {
|
|
|
580
706
|
context.filter = 'none';
|
|
581
707
|
context.globalCompositeOperation = 'destination-in';
|
|
582
708
|
context.beginPath();
|
|
583
|
-
var centerX = isNullOrUndefined(isSave) ?
|
|
584
|
-
var centerY = isNullOrUndefined(isSave) ?
|
|
585
|
-
var radius = isSave ? context.canvas.width / 2 :
|
|
709
|
+
var centerX = isNullOrUndefined(isSave) ? destLeft + (destWidth / 2) : context.canvas.width / 2;
|
|
710
|
+
var centerY = isNullOrUndefined(isSave) ? destTop + (destHeight / 2) : context.canvas.height / 2;
|
|
711
|
+
var radius = isSave ? context.canvas.width / 2 : destWidth / 2;
|
|
586
712
|
context.arc(centerX, centerY, radius, 0, Math.PI * 2);
|
|
587
713
|
context.closePath();
|
|
588
714
|
context.fill();
|
|
@@ -658,62 +784,62 @@ var Crop = /** @class */ (function () {
|
|
|
658
784
|
return;
|
|
659
785
|
}
|
|
660
786
|
var panRegion = '';
|
|
787
|
+
var degree = parent.transform.degree;
|
|
788
|
+
var _a = parent.panPoint.currentPannedPoint, x = _a.x, y = _a.y;
|
|
661
789
|
if (parent.rotateFlipColl.length > 0 && typeof (parent.rotateFlipColl[0]) === 'number'
|
|
662
|
-
&&
|
|
790
|
+
&& degree < 0) {
|
|
663
791
|
panRegion = this.getCurrCropState('reverse', true);
|
|
664
792
|
}
|
|
665
793
|
else {
|
|
666
794
|
panRegion = this.getCurrFlipState();
|
|
667
795
|
}
|
|
668
|
-
if (
|
|
669
|
-
if (
|
|
670
|
-
(panRegion === '
|
|
671
|
-
|| (parent.transform.degree === -270 && (panRegion === '' || panRegion === 'verticalHorizontal'
|
|
796
|
+
if (degree % 90 === 0 && degree % 180 !== 0) {
|
|
797
|
+
if (degree === 90 || (degree === -90 && (panRegion === 'horizontal' || panRegion === 'vertical'))
|
|
798
|
+
|| (degree === -270 && (panRegion === '' || panRegion === 'verticalHorizontal'
|
|
672
799
|
|| panRegion === 'horizontalVertical'))) {
|
|
673
800
|
if (panRegion === 'horizontal' || panRegion === '') {
|
|
674
|
-
parent.img.destLeft +=
|
|
801
|
+
parent.img.destLeft += y;
|
|
675
802
|
}
|
|
676
803
|
else {
|
|
677
|
-
parent.img.destLeft -=
|
|
804
|
+
parent.img.destLeft -= y;
|
|
678
805
|
}
|
|
679
806
|
if (panRegion === '' || panRegion === 'vertical') {
|
|
680
|
-
parent.img.destTop -=
|
|
807
|
+
parent.img.destTop -= x;
|
|
681
808
|
}
|
|
682
809
|
else {
|
|
683
|
-
parent.img.destTop +=
|
|
810
|
+
parent.img.destTop += x;
|
|
684
811
|
}
|
|
685
812
|
}
|
|
686
|
-
else if (
|
|
687
|
-
(panRegion === '
|
|
688
|
-
|| (parent.transform.degree === -90 && (panRegion === '' || panRegion === 'verticalHorizontal'
|
|
813
|
+
else if (degree === 270 || (degree === -270 && (panRegion === 'horizontal' || panRegion === 'vertical'))
|
|
814
|
+
|| (degree === -90 && (panRegion === '' || panRegion === 'verticalHorizontal'
|
|
689
815
|
|| panRegion === 'horizontalVertical'))) {
|
|
690
816
|
if (panRegion === '' || panRegion === 'horizontal') {
|
|
691
|
-
parent.img.destLeft -=
|
|
817
|
+
parent.img.destLeft -= y;
|
|
692
818
|
}
|
|
693
819
|
else {
|
|
694
|
-
parent.img.destLeft +=
|
|
820
|
+
parent.img.destLeft += y;
|
|
695
821
|
}
|
|
696
822
|
if (panRegion === '' || panRegion === 'vertical') {
|
|
697
|
-
parent.img.destTop +=
|
|
823
|
+
parent.img.destTop += x;
|
|
698
824
|
}
|
|
699
825
|
else {
|
|
700
|
-
parent.img.destTop -=
|
|
826
|
+
parent.img.destTop -= x;
|
|
701
827
|
}
|
|
702
828
|
}
|
|
703
829
|
}
|
|
704
830
|
else {
|
|
705
|
-
if (
|
|
831
|
+
if (degree === 180 || degree === -180) {
|
|
706
832
|
if (panRegion === '' || panRegion === 'vertical') {
|
|
707
|
-
parent.img.destLeft -=
|
|
833
|
+
parent.img.destLeft -= x;
|
|
708
834
|
}
|
|
709
835
|
else {
|
|
710
|
-
parent.img.destLeft +=
|
|
836
|
+
parent.img.destLeft += x;
|
|
711
837
|
}
|
|
712
838
|
if (panRegion === '' || panRegion === 'horizontal') {
|
|
713
|
-
parent.img.destTop -=
|
|
839
|
+
parent.img.destTop -= y;
|
|
714
840
|
}
|
|
715
841
|
else {
|
|
716
|
-
parent.img.destTop +=
|
|
842
|
+
parent.img.destTop += y;
|
|
717
843
|
}
|
|
718
844
|
}
|
|
719
845
|
}
|
|
@@ -721,22 +847,23 @@ var Crop = /** @class */ (function () {
|
|
|
721
847
|
Crop.prototype.crop = function (obj) {
|
|
722
848
|
var _this = this;
|
|
723
849
|
var parent = this.parent;
|
|
850
|
+
var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
|
|
724
851
|
if (!parent.disabled && parent.isImageLoaded) {
|
|
725
852
|
var object_1 = { isCropToolbar: parent.isCropToolbar };
|
|
726
853
|
if (parent.currObjType.isUndoAction && !object_1['isCropToolbar']) {
|
|
727
854
|
parent.notify('undo-redo', { prop: 'refreshUrc', value: { bool: null } });
|
|
728
855
|
}
|
|
729
|
-
var transitionArgs = { cancel: false, startPoint: { x:
|
|
730
|
-
|
|
731
|
-
y: parent.activeObj.activePoint.endY }, preventScaling: false };
|
|
856
|
+
var transitionArgs = { cancel: false, startPoint: { x: startX, y: startY },
|
|
857
|
+
endPoint: { x: endX, y: endY }, preventScaling: false };
|
|
732
858
|
if (!object_1['isCropToolbar'] && isBlazor() && parent.events && parent.events.cropping.hasDelegate === true) {
|
|
733
|
-
|
|
734
|
-
|
|
859
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
860
|
+
if (parent.currentToolbar === 'resize-toolbar') {
|
|
861
|
+
parent.dotNetRef.invokeMethodAsync('CropEventAsync', 'OnCrop', transitionArgs, null);
|
|
735
862
|
this.cropEvent(transitionArgs, obj, object_1);
|
|
736
863
|
}
|
|
737
864
|
else {
|
|
738
865
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
739
|
-
parent.dotNetRef.invokeMethodAsync('CropEventAsync', 'OnCrop', transitionArgs).then(function (args) {
|
|
866
|
+
parent.dotNetRef.invokeMethodAsync('CropEventAsync', 'OnCrop', transitionArgs, null).then(function (args) {
|
|
740
867
|
_this.cropEvent(args, obj, object_1);
|
|
741
868
|
});
|
|
742
869
|
}
|
|
@@ -767,47 +894,84 @@ var Crop = /** @class */ (function () {
|
|
|
767
894
|
this.isPreventScaling = false;
|
|
768
895
|
}
|
|
769
896
|
this.cropImg();
|
|
897
|
+
parent.notify('freehand-draw', { prop: 'resetStraightenPoint' });
|
|
898
|
+
parent.isCropTab = false;
|
|
770
899
|
parent.transform.zoomFactor = 0;
|
|
771
900
|
parent.setProperties({ zoomSettings: { zoomFactor: 1 } }, true);
|
|
772
901
|
parent.notify('transform', { prop: 'setPreviousZoomValue', onPropertyChange: false,
|
|
773
902
|
value: { previousZoomValue: parent.zoomSettings.zoomFactor } });
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
777
|
-
value: { operation: 'crop', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
778
|
-
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
779
|
-
previousCropObj: prevCropObj, previousText: null,
|
|
780
|
-
currentText: null, previousFilter: null, isCircleCrop: parent.isCircleCrop } });
|
|
781
|
-
if (!object['isCropToolbar']) {
|
|
782
|
-
parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
|
|
903
|
+
if (!Browser.isDevice) {
|
|
904
|
+
this.updateUndoRedoColl(prevObj, prevCropObj, object);
|
|
783
905
|
}
|
|
784
906
|
parent.notify('transform', { prop: 'setCropDimension', onPropertyChange: false,
|
|
785
907
|
value: { width: parent.cropObj.destPoints.width, height: parent.cropObj.destPoints.height } });
|
|
786
|
-
var aspectIcon =
|
|
787
|
-
var nonAspectIcon =
|
|
908
|
+
var aspectIcon = parent.element.querySelector('#' + parent.element.id + '_aspectratio');
|
|
909
|
+
var nonAspectIcon = parent.element.querySelector('#' + parent.element.id + '_nonaspectratio');
|
|
910
|
+
parent.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
|
|
788
911
|
if (!isBlazor() && !object['isCropToolbar'] && (isNullOrUndefined(aspectIcon) && isNullOrUndefined(nonAspectIcon))) {
|
|
789
912
|
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
|
|
790
913
|
isApplyBtn: false, isCropping: false, isZooming: null, cType: null } });
|
|
914
|
+
}
|
|
915
|
+
else if (!object['isCropToolbar']) {
|
|
791
916
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
917
|
+
if (parent.currentToolbar !== 'resize-toolbar') {
|
|
918
|
+
parent.updateToolbar(parent.element, 'imageLoaded');
|
|
919
|
+
}
|
|
792
920
|
}
|
|
793
|
-
|
|
794
|
-
|
|
921
|
+
this.resizeWrapper();
|
|
922
|
+
if (Browser.isDevice) {
|
|
923
|
+
this.updateUndoRedoColl(prevObj, prevCropObj, object);
|
|
795
924
|
}
|
|
925
|
+
transitionArgs = { startPoint: transitionArgs.startPoint, endPoint: transitionArgs.endPoint };
|
|
926
|
+
if (!object['isCropToolbar'] && isBlazor() && parent.events && parent.events.cropped.hasDelegate === true) {
|
|
927
|
+
parent.dotNetRef.invokeMethodAsync('CropEventAsync', 'Cropped', null, transitionArgs);
|
|
928
|
+
}
|
|
929
|
+
else { }
|
|
796
930
|
}
|
|
797
931
|
}
|
|
798
932
|
};
|
|
799
|
-
Crop.prototype.
|
|
933
|
+
Crop.prototype.updateUndoRedoColl = function (prevObj, prevCropObj, object) {
|
|
800
934
|
var parent = this.parent;
|
|
801
|
-
var
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
935
|
+
var currSelPtObj = { prevCurrSelectionPoint: parent.prevCurrSelectionPoint };
|
|
936
|
+
prevObj.currSelectionPoint = extend({}, currSelPtObj['prevCurrSelectionPoint'], {}, true);
|
|
937
|
+
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
938
|
+
value: { operation: 'crop', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
939
|
+
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
940
|
+
previousCropObj: prevCropObj, previousText: null,
|
|
941
|
+
currentText: null, previousFilter: null, isCircleCrop: parent.isCircleCrop } });
|
|
942
|
+
if (!object['isCropToolbar']) {
|
|
943
|
+
parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
|
|
806
944
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
945
|
+
};
|
|
946
|
+
Crop.prototype.resizeWrapper = function () {
|
|
947
|
+
var parent = this.parent;
|
|
948
|
+
if (Browser.isDevice && !isBlazor()) {
|
|
949
|
+
var elem = parent.element;
|
|
950
|
+
var ctxToolbar = elem.querySelector('#' + elem.id + '_contextualToolbarArea');
|
|
951
|
+
if (ctxToolbar.style.position === '' && !this.isTransformCrop) {
|
|
952
|
+
ctxToolbar.style.position = 'absolute';
|
|
953
|
+
parent.isStraightening = false;
|
|
954
|
+
parent.update();
|
|
955
|
+
parent.notify('filter', { prop: 'setAdjustmentValue', value: { adjustmentValue: parent.canvasFilter } });
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
else if (Browser.isDevice && isBlazor() && !this.isTransformCrop) {
|
|
959
|
+
parent.isStraightening = false;
|
|
960
|
+
parent.update();
|
|
961
|
+
var canvasWrapper = parent.element.querySelector('#' + parent.element.id + '_canvasWrapper');
|
|
962
|
+
if (canvasWrapper) {
|
|
963
|
+
canvasWrapper.style.height = (parseInt(canvasWrapper.style.height) + 2) + 'px';
|
|
964
|
+
}
|
|
965
|
+
parent.notify('filter', { prop: 'setAdjustmentValue', value: { adjustmentValue: parent.canvasFilter } });
|
|
810
966
|
}
|
|
967
|
+
};
|
|
968
|
+
Crop.prototype.calcRatio = function (obj, dimension) {
|
|
969
|
+
var parent = this.parent;
|
|
970
|
+
var degree = parent.transform.degree;
|
|
971
|
+
var _a = parent.img, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
972
|
+
var _b = dimension || parent.baseImgCanvas, width = _b.width, height = _b.height;
|
|
973
|
+
var widthRatio = (degree === 0 || degree % 180 === 0) ? width / destWidth : height / destWidth;
|
|
974
|
+
var heightRatio = (degree === 0 || degree % 180 === 0) ? height / destHeight : width / destHeight;
|
|
811
975
|
if (obj) {
|
|
812
976
|
obj['width'] = widthRatio;
|
|
813
977
|
obj['height'] = heightRatio;
|
|
@@ -816,19 +980,14 @@ var Crop = /** @class */ (function () {
|
|
|
816
980
|
};
|
|
817
981
|
Crop.prototype.isObjInImage = function (obj, dummyObj) {
|
|
818
982
|
var parent = this.parent;
|
|
819
|
-
var
|
|
820
|
-
var
|
|
821
|
-
var
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
(
|
|
826
|
-
(
|
|
827
|
-
(startY >= parent.img.destTop && endY <= (parent.img.destTop + parent.img.destHeight)) ||
|
|
828
|
-
(startY <= parent.img.destTop && endY >= parent.img.destTop) ||
|
|
829
|
-
(startY <= (parent.img.destTop + parent.img.destHeight) && endY >= (parent.img.destTop + parent.img.destHeight))) {
|
|
830
|
-
isInside = true;
|
|
831
|
-
}
|
|
983
|
+
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
984
|
+
var _b = obj.activePoint, startX = _b.startX, endX = _b.endX, startY = _b.startY, endY = _b.endY;
|
|
985
|
+
var isInside = ((startX >= destLeft && endX <= (destLeft + destWidth)) ||
|
|
986
|
+
(startX <= destLeft && endX >= destLeft) ||
|
|
987
|
+
(startX <= (destLeft + destWidth) && endX >= (destLeft + destWidth)) ||
|
|
988
|
+
(startY >= destTop && endY <= (destTop + destHeight)) ||
|
|
989
|
+
(startY <= destTop && endY >= destTop) ||
|
|
990
|
+
(startY <= (destTop + destHeight) && endY >= (destTop + destHeight)));
|
|
832
991
|
if (dummyObj) {
|
|
833
992
|
dummyObj['isInside'] = isInside;
|
|
834
993
|
}
|