@syncfusion/ej2-image-editor 23.2.6 → 24.1.41

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 (99) hide show
  1. package/CHANGELOG.md +3 -51
  2. package/dist/ej2-image-editor.umd.min.js +2 -2
  3. package/dist/ej2-image-editor.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-image-editor.es2015.js +7151 -4321
  5. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  6. package/dist/es6/ej2-image-editor.es5.js +7269 -4426
  7. package/dist/es6/ej2-image-editor.es5.js.map +1 -1
  8. package/dist/global/ej2-image-editor.min.js +2 -2
  9. package/dist/global/ej2-image-editor.min.js.map +1 -1
  10. package/dist/global/index.d.ts +1 -1
  11. package/package.json +12 -12
  12. package/src/image-editor/action/crop.d.ts +6 -0
  13. package/src/image-editor/action/crop.js +347 -188
  14. package/src/image-editor/action/draw.d.ts +35 -2
  15. package/src/image-editor/action/draw.js +1682 -881
  16. package/src/image-editor/action/export.js +90 -29
  17. package/src/image-editor/action/filter.d.ts +3 -1
  18. package/src/image-editor/action/filter.js +74 -94
  19. package/src/image-editor/action/freehand-draw.d.ts +4 -0
  20. package/src/image-editor/action/freehand-draw.js +259 -149
  21. package/src/image-editor/action/selection.d.ts +6 -1
  22. package/src/image-editor/action/selection.js +1133 -1091
  23. package/src/image-editor/action/shape.d.ts +7 -0
  24. package/src/image-editor/action/shape.js +921 -550
  25. package/src/image-editor/action/transform.d.ts +2 -0
  26. package/src/image-editor/action/transform.js +514 -346
  27. package/src/image-editor/action/undo-redo.d.ts +2 -0
  28. package/src/image-editor/action/undo-redo.js +137 -36
  29. package/src/image-editor/base/enum.d.ts +2 -1
  30. package/src/image-editor/base/enum.js +1 -0
  31. package/src/image-editor/base/image-editor-model.d.ts +37 -2
  32. package/src/image-editor/base/image-editor.d.ts +124 -3
  33. package/src/image-editor/base/image-editor.js +672 -171
  34. package/src/image-editor/base/interface.d.ts +69 -15
  35. package/src/image-editor/renderer/toolbar.d.ts +10 -0
  36. package/src/image-editor/renderer/toolbar.js +1371 -822
  37. package/styles/bootstrap-dark.css +113 -8
  38. package/styles/bootstrap.css +112 -7
  39. package/styles/bootstrap4.css +113 -8
  40. package/styles/bootstrap5-dark.css +113 -8
  41. package/styles/bootstrap5.css +113 -8
  42. package/styles/fabric-dark.css +114 -9
  43. package/styles/fabric.css +113 -8
  44. package/styles/fluent-dark.css +118 -9
  45. package/styles/fluent.css +118 -9
  46. package/styles/highcontrast-light.css +112 -7
  47. package/styles/highcontrast.css +116 -7
  48. package/styles/image-editor/_bootstrap-dark-definition.scss +3 -0
  49. package/styles/image-editor/_bootstrap-definition.scss +3 -0
  50. package/styles/image-editor/_bootstrap4-definition.scss +3 -0
  51. package/styles/image-editor/_bootstrap5-definition.scss +3 -0
  52. package/styles/image-editor/_fabric-dark-definition.scss +3 -0
  53. package/styles/image-editor/_fabric-definition.scss +3 -0
  54. package/styles/image-editor/_fluent-definition.scss +3 -0
  55. package/styles/image-editor/_fusionnew-definition.scss +3 -0
  56. package/styles/image-editor/_highcontrast-definition.scss +3 -0
  57. package/styles/image-editor/_highcontrast-light-definition.scss +3 -0
  58. package/styles/image-editor/_layout.scss +138 -4
  59. package/styles/image-editor/_material-dark-definition.scss +3 -0
  60. package/styles/image-editor/_material-definition.scss +3 -0
  61. package/styles/image-editor/_material3-definition.scss +3 -0
  62. package/styles/image-editor/_tailwind-definition.scss +3 -0
  63. package/styles/image-editor/_theme.scss +2 -4
  64. package/styles/image-editor/bootstrap-dark.css +113 -8
  65. package/styles/image-editor/bootstrap.css +112 -7
  66. package/styles/image-editor/bootstrap4.css +113 -8
  67. package/styles/image-editor/bootstrap5-dark.css +113 -8
  68. package/styles/image-editor/bootstrap5.css +113 -8
  69. package/styles/image-editor/fabric-dark.css +114 -9
  70. package/styles/image-editor/fabric.css +113 -8
  71. package/styles/image-editor/fluent-dark.css +118 -9
  72. package/styles/image-editor/fluent.css +118 -9
  73. package/styles/image-editor/highcontrast-light.css +112 -7
  74. package/styles/image-editor/highcontrast.css +116 -7
  75. package/styles/image-editor/icons/_bootstrap-dark.scss +60 -0
  76. package/styles/image-editor/icons/_bootstrap.scss +60 -0
  77. package/styles/image-editor/icons/_bootstrap4.scss +60 -0
  78. package/styles/image-editor/icons/_bootstrap5.scss +60 -0
  79. package/styles/image-editor/icons/_fabric-dark.scss +60 -0
  80. package/styles/image-editor/icons/_fabric.scss +60 -0
  81. package/styles/image-editor/icons/_fluent.scss +66 -0
  82. package/styles/image-editor/icons/_highcontrast-light.scss +60 -0
  83. package/styles/image-editor/icons/_highcontrast.scss +60 -0
  84. package/styles/image-editor/icons/_material-dark.scss +60 -0
  85. package/styles/image-editor/icons/_material.scss +60 -0
  86. package/styles/image-editor/icons/_material3.scss +60 -0
  87. package/styles/image-editor/icons/_tailwind.scss +60 -0
  88. package/styles/image-editor/material-dark.css +113 -8
  89. package/styles/image-editor/material.css +113 -8
  90. package/styles/image-editor/material3-dark.css +126 -9
  91. package/styles/image-editor/material3.css +126 -9
  92. package/styles/image-editor/tailwind-dark.css +114 -9
  93. package/styles/image-editor/tailwind.css +114 -9
  94. package/styles/material-dark.css +113 -8
  95. package/styles/material.css +113 -8
  96. package/styles/material3-dark.css +126 -9
  97. package/styles/material3.css +126 -9
  98. package/styles/tailwind-dark.css +114 -9
  99. package/styles/tailwind.css +114 -9
@@ -32,6 +32,8 @@ var Selection = /** @class */ (function () {
32
32
  this.touchTime = 0;
33
33
  this.resizedElement = '';
34
34
  this.isImageClarity = true;
35
+ this.isPinching = false;
36
+ this.isSliding = false;
35
37
  this.parent = parent;
36
38
  this.addEventListener();
37
39
  }
@@ -50,7 +52,7 @@ var Selection = /** @class */ (function () {
50
52
  this.parent.off('destroyed', this.destroy);
51
53
  };
52
54
  Selection.prototype.selection = function (args) {
53
- var _this = this;
55
+ var parent = this.parent;
54
56
  this.updatePrivateVariables();
55
57
  switch (args.prop) {
56
58
  case 'mouse-up':
@@ -89,7 +91,7 @@ var Selection = /** @class */ (function () {
89
91
  case 'clearUpperCanvas':
90
92
  if (this.isTouch) {
91
93
  setTimeout(function () {
92
- _this.parent.upperCanvas.getContext('2d').clearRect(0, 0, _this.parent.upperCanvas.width, _this.parent.upperCanvas.height);
94
+ parent.upperCanvas.getContext('2d').clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
93
95
  }, 550);
94
96
  }
95
97
  break;
@@ -205,13 +207,13 @@ var Selection = /** @class */ (function () {
205
207
  case 'annotate':
206
208
  this.currentDrawingShape = args.value['shape'];
207
209
  if (args.value['shape'] === 'text') {
208
- this.parent.activeObj.textSettings.fontSize = 100;
209
- this.parent.activeObj.keyHistory = 'Enter Text';
210
- this.parent.notify('shape', { prop: 'initializeTextShape', onPropertyChange: false,
210
+ parent.activeObj.textSettings.fontSize = 100;
211
+ parent.activeObj.keyHistory = 'Enter Text';
212
+ parent.notify('shape', { prop: 'initializeTextShape', onPropertyChange: false,
211
213
  value: { text: null, fontFamily: null, fontSize: null, bold: null, italic: null, strokeColor: null } });
212
214
  }
213
215
  else if (args.value['shape'] === 'path') {
214
- this.parent.activeObj.pointColl = [];
216
+ parent.activeObj.pointColl = [];
215
217
  }
216
218
  break;
217
219
  case 'getCurrentDrawingShape':
@@ -227,7 +229,7 @@ var Selection = /** @class */ (function () {
227
229
  this.adjustNEPoints(args.value['rectangle'], args.value['x'], args.value['y'], args.value['angle']);
228
230
  break;
229
231
  case 'adjustRotationPoints':
230
- this.adjustRotationPoints(args.value['rectangle'], args.value['x'], args.value['y'], args.value['angle']);
232
+ this.adjustRotationPoints(args.value['rectangle'], args.value['x'], args.value['y'], args.value['angle'], args.value['type'], args.value['elem']);
231
233
  break;
232
234
  case 'getResizeDirection':
233
235
  this.getResizeDirection(args.value['rectangle'], args.value['x'], args.value['y'], args.value['angle']);
@@ -256,9 +258,24 @@ var Selection = /** @class */ (function () {
256
258
  case 'upgradeImageQuality':
257
259
  this.upgradeImageQuality();
258
260
  break;
261
+ case 'getScaleRatio':
262
+ args.value['obj']['newScale'] = this.getScaleRatio(args.value['scale']);
263
+ break;
259
264
  case 'triggerShapeChange':
260
265
  this.triggerShapeChange(args.value['shapeResizingArgs'], args.value['shapeMovingArgs'], args.value['type']);
261
266
  break;
267
+ case 'limitDrag':
268
+ args.value['bool'] = this.limitDrag(args.value['isStart']);
269
+ break;
270
+ case 'applyTransformToImg':
271
+ this.applyTransformToImg(args.value['ctx']);
272
+ break;
273
+ case 'findTargetObj':
274
+ args.value['obj']['bool'] = this.findTargetObj(args.value['x'], args.value['y'], args.value['isCrop']);
275
+ break;
276
+ case 'setSliding':
277
+ this.isSliding = args.value['bool'];
278
+ break;
262
279
  }
263
280
  };
264
281
  Selection.prototype.getModuleName = function () {
@@ -293,10 +310,11 @@ var Selection = /** @class */ (function () {
293
310
  this.previousPoint = { x: 0, y: 0 };
294
311
  this.zoomType = 'Toolbar';
295
312
  this.isInitialTextEdited = false;
296
- this.dragCanvas = false;
313
+ this.dragCanvas = this.isPinching = false;
297
314
  this.isFhdCustomized = false;
298
315
  this.touchEndPoint = {};
299
316
  this.panDown = null;
317
+ this.isSliding = false;
300
318
  this.isFhdEditing = false;
301
319
  this.pathAdjustedIndex = null;
302
320
  this.touchTime = 0;
@@ -306,12 +324,13 @@ var Selection = /** @class */ (function () {
306
324
  this.resizedElement = '';
307
325
  };
308
326
  Selection.prototype.performTabAction = function () {
309
- if (this.parent.textArea.style.display === 'block') {
327
+ var parent = this.parent;
328
+ if (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') {
310
329
  var allowUndoRedoPush = this.applyCurrShape(false);
311
- this.parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
330
+ parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
312
331
  value: { x: null, y: null, isMouseDown: null } });
313
332
  if (allowUndoRedoPush) {
314
- this.parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
333
+ parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
315
334
  }
316
335
  }
317
336
  };
@@ -321,6 +340,7 @@ var Selection = /** @class */ (function () {
321
340
  };
322
341
  Selection.prototype.getMouseCursor = function (actObj, x, y, isCropSelection, isApply) {
323
342
  var rotationCirclePoint = this.getTransRotationPoint(actObj);
343
+ var radius = actObj.bottomCenterCircle.radius;
324
344
  var cursor = 'default';
325
345
  var ratio = isApply ? 0 : ((actObj.topLeftCircle.radius * 2));
326
346
  if (x >= (actObj.topLeftCircle.startX - ratio) &&
@@ -382,10 +402,10 @@ var Selection = /** @class */ (function () {
382
402
  }
383
403
  }
384
404
  else if (rotationCirclePoint && !isApply &&
385
- x >= (rotationCirclePoint.x - (actObj.bottomCenterCircle.radius + 2)) &&
386
- x <= rotationCirclePoint.x + (actObj.bottomCenterCircle.radius + 2) &&
387
- y >= rotationCirclePoint.y - (actObj.bottomCenterCircle.radius + 2) &&
388
- y <= rotationCirclePoint.y + (actObj.bottomCenterCircle.radius + 2)) {
405
+ x >= (rotationCirclePoint.x - (radius + 2)) &&
406
+ x <= rotationCirclePoint.x + (radius + 2) &&
407
+ y >= rotationCirclePoint.y - (radius + 2) &&
408
+ y <= rotationCirclePoint.y + (radius + 2)) {
389
409
  cursor = 'grabbing';
390
410
  }
391
411
  else {
@@ -397,24 +417,22 @@ var Selection = /** @class */ (function () {
397
417
  var parent = this.parent;
398
418
  var frameObject = { bool: null };
399
419
  parent.notify('toolbar', { prop: 'getFrameToolbar', onPropertyChange: false, value: { obj: frameObject } });
400
- if (parent.isResize || frameObject['bool']) {
420
+ if (parent.isResize || this.isSliding || frameObject['bool']) {
401
421
  parent.upperCanvas.style.cursor = 'default';
402
422
  return;
403
423
  }
404
- var lowerCanvas = document.querySelector('#' + parent.element.id + '_lowerCanvas');
405
- var upperCanvas = document.querySelector('#' + parent.element.id + '_upperCanvas');
406
424
  var isCropSelection = false;
407
425
  var splitWords;
408
426
  if (this.currentDrawingShape !== '') {
409
- upperCanvas.style.cursor = parent.cursor = 'crosshair';
427
+ parent.upperCanvas.style.cursor = parent.cursor = 'crosshair';
410
428
  return;
411
429
  }
412
430
  if (parent.currObjType.isDragging) {
413
431
  if (this.dragElement === '') {
414
- upperCanvas.style.cursor = parent.cursor = 'move';
432
+ parent.upperCanvas.style.cursor = parent.cursor = 'move';
415
433
  }
416
434
  else {
417
- upperCanvas.style.cursor = parent.cursor = this.dragElement;
435
+ parent.upperCanvas.style.cursor = parent.cursor = this.dragElement;
418
436
  }
419
437
  return;
420
438
  }
@@ -429,9 +447,9 @@ var Selection = /** @class */ (function () {
429
447
  isCropSelection = true;
430
448
  }
431
449
  if (!isCropSelection && parent.togglePan) {
432
- lowerCanvas.style.cursor = upperCanvas.style.cursor = parent.cursor = 'grab';
450
+ parent.lowerCanvas.style.cursor = parent.upperCanvas.style.cursor = parent.cursor = 'grab';
433
451
  }
434
- var cursor = upperCanvas.style.cursor;
452
+ var cursor = parent.upperCanvas.style.cursor;
435
453
  var actObj = extend({}, parent.activeObj, {}, true);
436
454
  this.cursorTargetId = actObj.currIndex;
437
455
  var degree = void 0;
@@ -445,53 +463,52 @@ var Selection = /** @class */ (function () {
445
463
  degree = 360 + degree;
446
464
  }
447
465
  if (actObj.shape === 'line' || actObj.shape === 'arrow') {
448
- this.setCursorForLineArrow(actObj, x, y, upperCanvas);
466
+ this.setCursorForLineArrow(actObj, x, y, parent.upperCanvas);
449
467
  }
450
468
  else if (actObj.shape === 'path') {
451
- this.setCursorForPath(actObj, x, y, upperCanvas);
469
+ this.setCursorForPath(actObj, x, y, parent.upperCanvas);
452
470
  }
453
471
  else if (!isNullOrUndefined(actObj.rotatedAngle) && actObj.rotatedAngle !== 0) {
454
- this.setCursorForRotatedObject(actObj, x, y, upperCanvas);
472
+ this.setCursorForRotatedObject(actObj, x, y, parent.upperCanvas);
455
473
  }
456
474
  else {
457
- upperCanvas.style.cursor = parent.cursor = this.getMouseCursor(actObj, x, y, isCropSelection, false);
458
- if ((actObj.shape === 'text') && (parent.cursor === 'n-resize' ||
459
- parent.cursor === 's-resize' || parent.cursor === 'e-resize' ||
460
- parent.cursor === 'w-resize')) {
461
- upperCanvas.style.cursor = parent.cursor = 'move';
475
+ parent.upperCanvas.style.cursor = parent.cursor = this.getMouseCursor(actObj, x, y, isCropSelection, false);
476
+ var cursorColl = ['n-resize', 's-resize', 'e-resize', 'w-resize'];
477
+ if ((actObj.shape === 'text') && cursorColl.indexOf(parent.cursor) > -1) {
478
+ parent.upperCanvas.style.cursor = parent.cursor = 'move';
462
479
  }
463
480
  }
464
481
  if (cursor === 'default' && parent.cursor === 'default' && isCropSelection) {
465
- upperCanvas.style.cursor = parent.cursor = 'grab';
482
+ parent.upperCanvas.style.cursor = parent.cursor = 'grab';
466
483
  }
467
484
  if (cursor === 'grab' && parent.cursor === 'default') {
468
- upperCanvas.style.cursor = parent.cursor = 'grab';
485
+ parent.upperCanvas.style.cursor = parent.cursor = 'grab';
469
486
  }
470
487
  }
471
488
  else if (parent.togglePan && !parent.togglePen) {
472
- lowerCanvas.style.cursor = upperCanvas.style.cursor = parent.cursor = 'grab';
489
+ parent.lowerCanvas.style.cursor = parent.upperCanvas.style.cursor = parent.cursor = 'grab';
473
490
  }
474
491
  else {
475
492
  if (parent.currObjType.isCustomCrop || parent.togglePen) {
476
- upperCanvas.style.cursor = parent.cursor = 'crosshair';
493
+ parent.upperCanvas.style.cursor = parent.cursor = 'crosshair';
477
494
  }
478
495
  else {
479
- upperCanvas.style.cursor = parent.cursor = 'default';
496
+ parent.upperCanvas.style.cursor = parent.cursor = 'default';
480
497
  }
481
498
  }
482
499
  if (parent.cursor === 'default' || parent.cursor === 'grab') {
483
- var cursor = upperCanvas.style.cursor;
500
+ var cursor = parent.upperCanvas.style.cursor;
484
501
  if (parent.objColl.length > 0 && (parent.cursor !== 'grab' || !isCropSelection)) {
485
- this.setCursorFromObj(x, y, parent.objColl, upperCanvas, isCropSelection);
502
+ this.setCursorFromObj(x, y, parent.objColl, parent.upperCanvas, isCropSelection);
486
503
  }
487
504
  if (cursor === 'grab' && parent.cursor === 'default') {
488
- upperCanvas.style.cursor = parent.cursor = 'grab';
505
+ parent.upperCanvas.style.cursor = parent.cursor = 'grab';
489
506
  }
490
507
  }
491
508
  if ((parent.cursor === 'default' || parent.cursor === 'grab')
492
509
  && parent.pointColl[0] && (parent.cursor !== 'grab' || !isCropSelection)
493
510
  && !parent.currObjType.isDragging && !parent.currObjType.isResize) {
494
- this.setCursorForFreehandDrawing(x, y, upperCanvas);
511
+ this.setCursorForFreehandDrawing(x, y, parent.upperCanvas);
495
512
  }
496
513
  };
497
514
  Selection.prototype.setCursorForPath = function (actObj, x, y, upperCanvas) {
@@ -500,7 +517,7 @@ var Selection = /** @class */ (function () {
500
517
  if (parent.cursor === 'default') {
501
518
  var obj = extend({}, actObj, null, true);
502
519
  var isMove = false;
503
- for (var i = 1; i < actObj.pointColl.length; i++) {
520
+ for (var i = 1, len = actObj.pointColl.length; i < len; i++) {
504
521
  if (isMove) {
505
522
  break;
506
523
  }
@@ -510,16 +527,17 @@ var Selection = /** @class */ (function () {
510
527
  obj.activePoint.endY = actObj.pointColl[i].y;
511
528
  parent.notify('shape', { prop: 'setPointCollForLineArrow', onPropertyChange: false,
512
529
  value: { obj: obj } });
513
- for (var j = 0; j < obj.pointColl.length; j++) {
530
+ var radius = actObj.topLeftCircle.radius;
531
+ for (var j = 0, jLen = obj.pointColl.length; j < jLen; j++) {
514
532
  var point = obj.pointColl[j];
515
- if (!isNullOrUndefined(point.x - (actObj.topLeftCircle.radius * 2)) &&
516
- !isNullOrUndefined(point.x + (actObj.topLeftCircle.radius * 2)) &&
517
- !isNullOrUndefined(point.y - (actObj.topLeftCircle.radius * 2)) &&
518
- !isNullOrUndefined(point.y + (actObj.topLeftCircle.radius * 2)) &&
519
- x >= (point.x - (actObj.topLeftCircle.radius * 2)) &&
520
- x <= (point.x + (actObj.topLeftCircle.radius * 2)) &&
521
- y >= (point.y - (actObj.topLeftCircle.radius * 2)) &&
522
- y <= (point.y + (actObj.topLeftCircle.radius * 2))) {
533
+ if (!isNullOrUndefined(point.x - (radius * 2)) &&
534
+ !isNullOrUndefined(point.x + (radius * 2)) &&
535
+ !isNullOrUndefined(point.y - (radius * 2)) &&
536
+ !isNullOrUndefined(point.y + (radius * 2)) &&
537
+ x >= (point.x - (radius * 2)) &&
538
+ x <= (point.x + (radius * 2)) &&
539
+ y >= (point.y - (radius * 2)) &&
540
+ y <= (point.y + (radius * 2))) {
523
541
  upperCanvas.style.cursor = parent.cursor = 'move';
524
542
  isMove = true;
525
543
  break;
@@ -534,10 +552,11 @@ var Selection = /** @class */ (function () {
534
552
  };
535
553
  Selection.prototype.setCursorForLineArrow = function (actObj, x, y, upperCanvas) {
536
554
  var index;
537
- for (var i = 0; i < actObj.pointColl.length; i++) {
555
+ var radius = actObj.topLeftCircle.radius;
556
+ for (var i = 0, len = actObj.pointColl.length; i < len; i++) {
538
557
  var point = actObj.pointColl[i];
539
- if (x >= (point.x - (actObj.topLeftCircle.radius * 2)) && x <= (point.x + (actObj.topLeftCircle.radius * 2)) &&
540
- y >= (point.y - (actObj.topLeftCircle.radius * 2)) && y <= (point.y + (actObj.topLeftCircle.radius * 2))) {
558
+ if (x >= (point.x - (radius * 2)) && x <= (point.x + (radius * 2)) &&
559
+ y >= (point.y - (radius * 2)) && y <= (point.y + (radius * 2))) {
541
560
  upperCanvas.style.cursor = this.parent.cursor = 'move';
542
561
  index = i;
543
562
  break;
@@ -551,67 +570,46 @@ var Selection = /** @class */ (function () {
551
570
  Selection.prototype.setCursorForRotatedObject = function (actObj, x, y, upperCanvas) {
552
571
  this.resizedElement = '';
553
572
  var parent = this.parent;
554
- if (x >= (actObj.horTopLinePointColl[0].x - (actObj.bottomCenterCircle.radius + 2)) &&
555
- x <= (actObj.horTopLinePointColl[0].x + (actObj.bottomCenterCircle.radius + 2)) &&
556
- y >= (actObj.horTopLinePointColl[0].y - (actObj.bottomCenterCircle.radius + 2)) &&
557
- y <= (actObj.horTopLinePointColl[0].y + (actObj.bottomCenterCircle.radius + 2))) {
573
+ var radius = actObj.bottomCenterCircle.radius;
574
+ var horTP = actObj.horTopLinePointColl[Math.round(actObj.horTopLinePointColl.length / 2)];
575
+ var horTP1 = actObj.horTopLinePointColl[Math.round(actObj.horTopLinePointColl.length - 1)];
576
+ var verLP = actObj.verLeftLinePointColl[Math.round(actObj.verLeftLinePointColl.length / 2)];
577
+ var verRP = actObj.verRightLinePointColl[Math.round(actObj.verRightLinePointColl.length / 2)];
578
+ var horBP = actObj.horBottomLinePointColl[Math.round(actObj.horBottomLinePointColl.length / 2)];
579
+ var horBP1 = actObj.horBottomLinePointColl[Math.round(actObj.horBottomLinePointColl.length - 1)];
580
+ var rotCP = actObj.rotationCirclePointColl;
581
+ var horTP0 = actObj.horTopLinePointColl[0];
582
+ var horBP0 = actObj.horBottomLinePointColl[0];
583
+ if (x >= (horTP0.x - (radius + 2)) && x <= (horTP0.x + (radius + 2)) && y >= (horTP0.y - (radius + 2)) &&
584
+ y <= (horTP0.y + (radius + 2))) {
558
585
  upperCanvas.style.cursor = parent.cursor = 'nw-resize';
559
586
  }
560
- else if (x >= (actObj.horTopLinePointColl[Math.round(actObj.horTopLinePointColl.length / 2)].x - 5) &&
561
- x <= (actObj.horTopLinePointColl[Math.round(actObj.horTopLinePointColl.length / 2)].x + 5) &&
562
- y >= (actObj.horTopLinePointColl[Math.round(actObj.horTopLinePointColl.length / 2)].y - 5) &&
563
- y <= (actObj.horTopLinePointColl[Math.round(actObj.horTopLinePointColl.length / 2)].y + 5)) {
587
+ else if (x >= (horTP.x - 5) && x <= (horTP.x + 5) && y >= (horTP.y - 5) && y <= (horTP.y + 5)) {
564
588
  upperCanvas.style.cursor = parent.cursor = this.resizedElement = 'n-resize';
565
589
  }
566
- else if (x >= (actObj.horTopLinePointColl[Math.round(actObj.horTopLinePointColl.length - 1)].x -
567
- (actObj.bottomCenterCircle.radius + 2)) &&
568
- x <= (actObj.horTopLinePointColl[Math.round(actObj.horTopLinePointColl.length - 1)].x +
569
- (actObj.bottomCenterCircle.radius + 2)) &&
570
- y >= (actObj.horTopLinePointColl[Math.round(actObj.horTopLinePointColl.length - 1)].y -
571
- (actObj.bottomCenterCircle.radius + 2)) &&
572
- y <= (actObj.horTopLinePointColl[Math.round(actObj.horTopLinePointColl.length - 1)].y +
573
- (actObj.bottomCenterCircle.radius + 2))) {
590
+ else if (x >= (horTP1.x - (radius + 2)) && x <= (horTP1.x + (radius + 2)) && y >= (horTP1.y - (radius + 2)) &&
591
+ y <= (horTP1.y + (radius + 2))) {
574
592
  upperCanvas.style.cursor = parent.cursor = 'ne-resize';
575
593
  }
576
- else if (x >= (actObj.verLeftLinePointColl[Math.round(actObj.verLeftLinePointColl.length / 2)].x - 5) &&
577
- x <= (actObj.verLeftLinePointColl[Math.round(actObj.verLeftLinePointColl.length / 2)].x + 5) &&
578
- y >= (actObj.verLeftLinePointColl[Math.round(actObj.verLeftLinePointColl.length / 2)].y - 5)
579
- && y <= (actObj.verLeftLinePointColl[Math.round(actObj.verLeftLinePointColl.length / 2)].y + 5)) {
594
+ else if (x >= (verLP.x - 5) && x <= (verLP.x + 5) && y >= (verLP.y - 5) && y <= (verLP.y + 5)) {
580
595
  upperCanvas.style.cursor = parent.cursor = this.resizedElement = 'w-resize';
581
596
  }
582
- else if (x >= (actObj.verRightLinePointColl[Math.round(actObj.verRightLinePointColl.length / 2)].x - 5) &&
583
- x <= (actObj.verRightLinePointColl[Math.round(actObj.verRightLinePointColl.length / 2)].x + 5)
584
- && y >= (actObj.verRightLinePointColl[Math.round(actObj.verRightLinePointColl.length / 2)].y - 5) &&
585
- y <= (actObj.verRightLinePointColl[Math.round(actObj.verRightLinePointColl.length / 2)].y + 5)) {
597
+ else if (x >= (verRP.x - 5) && x <= (verRP.x + 5) && y >= (verRP.y - 5) && y <= (verRP.y + 5)) {
586
598
  upperCanvas.style.cursor = parent.cursor = this.resizedElement = 'e-resize';
587
599
  }
588
- else if (x >= (actObj.horBottomLinePointColl[0].x - (actObj.bottomCenterCircle.radius + 2)) &&
589
- x <= (actObj.horBottomLinePointColl[0].x + (actObj.bottomCenterCircle.radius + 2)) &&
590
- y >= (actObj.horBottomLinePointColl[0].y - (actObj.bottomCenterCircle.radius + 2)) &&
591
- y <= (actObj.horBottomLinePointColl[0].y + (actObj.bottomCenterCircle.radius + 2))) {
600
+ else if (x >= (horBP0.x - (radius + 2)) && x <= (horBP0.x + (radius + 2)) && y >= (horBP0.y - (radius + 2)) &&
601
+ y <= (horBP0.y + (radius + 2))) {
592
602
  upperCanvas.style.cursor = parent.cursor = 'sw-resize';
593
603
  }
594
- else if (x >= (actObj.horBottomLinePointColl[Math.round(actObj.horBottomLinePointColl.length / 2)].x - 5) &&
595
- x <= (actObj.horBottomLinePointColl[Math.round(actObj.horBottomLinePointColl.length / 2)].x + 5) &&
596
- y >= (actObj.horBottomLinePointColl[Math.round(actObj.horBottomLinePointColl.length / 2)].y - 5) &&
597
- y <= (actObj.horBottomLinePointColl[Math.round(actObj.horBottomLinePointColl.length / 2)].y + 5)) {
604
+ else if (x >= (horBP.x - 5) && x <= (horBP.x + 5) && y >= (horBP.y - 5) && y <= (horBP.y + 5)) {
598
605
  upperCanvas.style.cursor = parent.cursor = this.resizedElement = 's-resize';
599
606
  }
600
- else if (x >= (actObj.horBottomLinePointColl[Math.round(actObj.horBottomLinePointColl.length - 1)].x -
601
- (actObj.bottomCenterCircle.radius + 2)) &&
602
- x <= (actObj.horBottomLinePointColl[Math.round(actObj.horBottomLinePointColl.length - 1)].x +
603
- (actObj.bottomCenterCircle.radius + 2)) &&
604
- y >= (actObj.horBottomLinePointColl[Math.round(actObj.horBottomLinePointColl.length - 1)].y -
605
- (actObj.bottomCenterCircle.radius + 2)) &&
606
- y <= (actObj.horBottomLinePointColl[Math.round(actObj.horBottomLinePointColl.length - 1)].y +
607
- (actObj.bottomCenterCircle.radius + 2))) {
607
+ else if (x >= (horBP1.x - (radius + 2)) && x <= (horBP1.x + (radius + 2)) && y >= (horBP1.y - (radius + 2)) &&
608
+ y <= (horBP1.y + (radius + 2))) {
608
609
  upperCanvas.style.cursor = parent.cursor = 'se-resize';
609
610
  }
610
- else if (actObj.rotationCirclePointColl &&
611
- x >= (actObj.rotationCirclePointColl.x - (actObj.bottomCenterCircle.radius + 2)) &&
612
- x <= actObj.rotationCirclePointColl.x + (actObj.bottomCenterCircle.radius + 2) &&
613
- y >= actObj.rotationCirclePointColl.y - (actObj.bottomCenterCircle.radius + 2) &&
614
- y <= actObj.rotationCirclePointColl.y + (actObj.bottomCenterCircle.radius + 2)) {
611
+ else if (rotCP && x >= (rotCP.x - (radius + 2)) && x <= rotCP.x + (radius + 2) && y >= rotCP.y - (radius + 2) &&
612
+ y <= rotCP.y + (radius + 2)) {
615
613
  upperCanvas.style.cursor = parent.cursor = 'grabbing';
616
614
  }
617
615
  else {
@@ -623,10 +621,8 @@ var Selection = /** @class */ (function () {
623
621
  }
624
622
  if (parent.cursor === 'default') {
625
623
  for (var i = 0, len = actObj.horTopLinePointColl.length; i < len; i++) {
626
- if (x >= (actObj.horTopLinePointColl[i].x - 5) &&
627
- x <= (actObj.horTopLinePointColl[i].x + 5) &&
628
- y >= (actObj.horTopLinePointColl[i].y - 5) &&
629
- y <= (actObj.horTopLinePointColl[i].y + 5)) {
624
+ var horTP_1 = actObj.horTopLinePointColl[i];
625
+ if (x >= (horTP_1.x - 5) && x <= (horTP_1.x + 5) && y >= (horTP_1.y - 5) && y <= (horTP_1.y + 5)) {
630
626
  upperCanvas.style.cursor = parent.cursor = this.resizedElement = 'n-resize';
631
627
  break;
632
628
  }
@@ -634,10 +630,8 @@ var Selection = /** @class */ (function () {
634
630
  }
635
631
  if (parent.cursor === 'default') {
636
632
  for (var i = 0, len = actObj.horBottomLinePointColl.length; i < len; i++) {
637
- if (x >= (actObj.horBottomLinePointColl[i].x - 5) &&
638
- x <= (actObj.horBottomLinePointColl[i].x + 5) &&
639
- y >= (actObj.horBottomLinePointColl[i].y - 5) &&
640
- y <= (actObj.horBottomLinePointColl[i].y + 5)) {
633
+ var horBP_1 = actObj.horBottomLinePointColl[i];
634
+ if (x >= (horBP_1.x - 5) && x <= (horBP_1.x + 5) && y >= (horBP_1.y - 5) && y <= (horBP_1.y + 5)) {
641
635
  upperCanvas.style.cursor = parent.cursor = this.resizedElement = 's-resize';
642
636
  break;
643
637
  }
@@ -645,10 +639,8 @@ var Selection = /** @class */ (function () {
645
639
  }
646
640
  if (parent.cursor === 'default') {
647
641
  for (var i = 0, len = actObj.verLeftLinePointColl.length; i < len; i++) {
648
- if (x >= (actObj.verLeftLinePointColl[i].x - 5) &&
649
- x <= (actObj.verLeftLinePointColl[i].x + 5) &&
650
- y >= (actObj.verLeftLinePointColl[i].y - 5) &&
651
- y <= (actObj.verLeftLinePointColl[i].y + 5)) {
642
+ var verLP_1 = actObj.verLeftLinePointColl[i];
643
+ if (x >= (verLP_1.x - 5) && x <= (verLP_1.x + 5) && y >= (verLP_1.y - 5) && y <= (verLP_1.y + 5)) {
652
644
  upperCanvas.style.cursor = parent.cursor = this.resizedElement = 'w-resize';
653
645
  break;
654
646
  }
@@ -656,10 +648,8 @@ var Selection = /** @class */ (function () {
656
648
  }
657
649
  if (parent.cursor === 'default') {
658
650
  for (var i = 0, len = actObj.verRightLinePointColl.length; i < len; i++) {
659
- if (x >= (actObj.verRightLinePointColl[i].x - 5) &&
660
- x <= (actObj.verRightLinePointColl[i].x + 5) &&
661
- y >= (actObj.verRightLinePointColl[i].y - 5) &&
662
- y <= (actObj.verRightLinePointColl[i].y + 5)) {
651
+ var verRP_1 = actObj.verRightLinePointColl[i];
652
+ if (x >= (verRP_1.x - 5) && x <= (verRP_1.x + 5) && y >= (verRP_1.y - 5) && y <= (verRP_1.y + 5)) {
663
653
  upperCanvas.style.cursor = parent.cursor = this.resizedElement = 'e-resize';
664
654
  break;
665
655
  }
@@ -686,62 +676,64 @@ var Selection = /** @class */ (function () {
686
676
  };
687
677
  Selection.prototype.getResizeElement = function (degree, element) {
688
678
  var resizeMappings = [];
689
- if (element === 'nw-resize') {
690
- resizeMappings = [
691
- [337.5, 22.5, 'nw-resize'], [22.5, 67.5, 'n-resize'], [67.5, 112.5, 'ne-resize'],
692
- [112.5, 157.5, 'e-resize'], [157.5, 202.5, 'se-resize'],
693
- [202.5, 247.5, 's-resize'], [247.5, 292.5, 'sw-resize'],
694
- [292.5, 337.5, 'w-resize']
695
- ];
696
- }
697
- else if (element === 'n-resize') {
698
- resizeMappings = [
699
- [337.5, 22.5, 'n-resize'], [22.5, 67.5, 'ne-resize'], [67.5, 112.5, 'e-resize'],
700
- [112.5, 157.5, 'se-resize'], [157.5, 202.5, 's-resize'], [202.5, 247.5, 'sw-resize'],
701
- [247.5, 292.5, 'w-resize'], [292.5, 337.5, 'nw-resize']
702
- ];
703
- }
704
- else if (element === 'ne-resize') {
705
- resizeMappings = [
706
- [337.5, 22.5, 'ne-resize'], [22.5, 67.5, 'e-resize'],
707
- [67.5, 112.5, 'se-resize'], [112.5, 157.5, 's-resize'], [157.5, 202.5, 'sw-resize'],
708
- [202.5, 247.5, 'w-resize'], [247.5, 292.5, 'nw-resize'], [292.5, 337.5, 'n-resize']
709
- ];
710
- }
711
- else if (element === 'e-resize') {
712
- resizeMappings = [
713
- [337.5, 22.5, 'e-resize'], [22.5, 67.5, 'se-resize'], [67.5, 112.5, 's-resize'],
714
- [112.5, 157.5, 'sw-resize'], [157.5, 202.5, 'w-resize'], [202.5, 247.5, 'nw-resize'],
715
- [247.5, 292.5, 'n-resize'], [292.5, 337.5, 'ne-resize']
716
- ];
717
- }
718
- else if (element === 'se-resize') {
719
- resizeMappings = [
720
- [337.5, 22.5, 'se-resize'], [22.5, 67.5, 's-resize'], [67.5, 112.5, 'sw-resize'],
721
- [112.5, 157.5, 'w-resize'], [157.5, 202.5, 'nw-resize'], [202.5, 247.5, 'n-resize'],
722
- [247.5, 292.5, 'ne-resize'], [292.5, 337.5, 'e-resize']
723
- ];
724
- }
725
- else if (element === 's-resize') {
726
- resizeMappings = [
727
- [337.5, 22.5, 's-resize'], [22.5, 67.5, 'sw-resize'], [67.5, 112.5, 'w-resize'],
728
- [112.5, 157.5, 'nw-resize'], [157.5, 202.5, 'n-resize'], [202.5, 247.5, 'ne-resize'],
729
- [247.5, 292.5, 'e-resize'], [292.5, 337.5, 'se-resize']
730
- ];
731
- }
732
- else if (element === 'sw-resize') {
733
- resizeMappings = [
734
- [337.5, 22.5, 'sw-resize'], [22.5, 67.5, 'w-resize'], [67.5, 112.5, 'nw-resize'],
735
- [112.5, 157.5, 'n-resize'], [157.5, 202.5, 'ne-resize'], [202.5, 247.5, 'e-resize'],
736
- [247.5, 292.5, 'se-resize'], [292.5, 337.5, 's-resize']
737
- ];
738
- }
739
- else if (element === 'w-resize') {
740
- resizeMappings = [
741
- [337.5, 22.5, 'w-resize'], [22.5, 67.5, 'nw-resize'], [67.5, 112.5, 'n-resize'],
742
- [112.5, 157.5, 'ne-resize'], [157.5, 202.5, 'e-resize'], [202.5, 247.5, 'se-resize'],
743
- [247.5, 292.5, 's-resize'], [292.5, 337.5, 'sw-resize']
744
- ];
679
+ switch (element) {
680
+ case 'nw-resize':
681
+ resizeMappings = [
682
+ [337.5, 22.5, 'nw-resize'], [22.5, 67.5, 'n-resize'], [67.5, 112.5, 'ne-resize'],
683
+ [112.5, 157.5, 'e-resize'], [157.5, 202.5, 'se-resize'],
684
+ [202.5, 247.5, 's-resize'], [247.5, 292.5, 'sw-resize'],
685
+ [292.5, 337.5, 'w-resize']
686
+ ];
687
+ break;
688
+ case 'n-resize':
689
+ resizeMappings = [
690
+ [337.5, 22.5, 'n-resize'], [22.5, 67.5, 'ne-resize'], [67.5, 112.5, 'e-resize'],
691
+ [112.5, 157.5, 'se-resize'], [157.5, 202.5, 's-resize'], [202.5, 247.5, 'sw-resize'],
692
+ [247.5, 292.5, 'w-resize'], [292.5, 337.5, 'nw-resize']
693
+ ];
694
+ break;
695
+ case 'ne-resize':
696
+ resizeMappings = [
697
+ [337.5, 22.5, 'ne-resize'], [22.5, 67.5, 'e-resize'],
698
+ [67.5, 112.5, 'se-resize'], [112.5, 157.5, 's-resize'], [157.5, 202.5, 'sw-resize'],
699
+ [202.5, 247.5, 'w-resize'], [247.5, 292.5, 'nw-resize'], [292.5, 337.5, 'n-resize']
700
+ ];
701
+ break;
702
+ case 'e-resize':
703
+ resizeMappings = [
704
+ [337.5, 22.5, 'e-resize'], [22.5, 67.5, 'se-resize'], [67.5, 112.5, 's-resize'],
705
+ [112.5, 157.5, 'sw-resize'], [157.5, 202.5, 'w-resize'], [202.5, 247.5, 'nw-resize'],
706
+ [247.5, 292.5, 'n-resize'], [292.5, 337.5, 'ne-resize']
707
+ ];
708
+ break;
709
+ case 'se-resize':
710
+ resizeMappings = [
711
+ [337.5, 22.5, 'se-resize'], [22.5, 67.5, 's-resize'], [67.5, 112.5, 'sw-resize'],
712
+ [112.5, 157.5, 'w-resize'], [157.5, 202.5, 'nw-resize'], [202.5, 247.5, 'n-resize'],
713
+ [247.5, 292.5, 'ne-resize'], [292.5, 337.5, 'e-resize']
714
+ ];
715
+ break;
716
+ case 's-resize':
717
+ resizeMappings = [
718
+ [337.5, 22.5, 's-resize'], [22.5, 67.5, 'sw-resize'], [67.5, 112.5, 'w-resize'],
719
+ [112.5, 157.5, 'nw-resize'], [157.5, 202.5, 'n-resize'], [202.5, 247.5, 'ne-resize'],
720
+ [247.5, 292.5, 'e-resize'], [292.5, 337.5, 'se-resize']
721
+ ];
722
+ break;
723
+ case 'sw-resize':
724
+ resizeMappings = [
725
+ [337.5, 22.5, 'sw-resize'], [22.5, 67.5, 'w-resize'], [67.5, 112.5, 'nw-resize'],
726
+ [112.5, 157.5, 'n-resize'], [157.5, 202.5, 'ne-resize'], [202.5, 247.5, 'e-resize'],
727
+ [247.5, 292.5, 'se-resize'], [292.5, 337.5, 's-resize']
728
+ ];
729
+ break;
730
+ case 'w-resize':
731
+ resizeMappings = [
732
+ [337.5, 22.5, 'w-resize'], [22.5, 67.5, 'nw-resize'], [67.5, 112.5, 'n-resize'],
733
+ [112.5, 157.5, 'ne-resize'], [157.5, 202.5, 'e-resize'], [202.5, 247.5, 'se-resize'],
734
+ [247.5, 292.5, 's-resize'], [292.5, 337.5, 'sw-resize']
735
+ ];
736
+ break;
745
737
  }
746
738
  var positiveDegree = degree < 0 ? 360 - Math.abs(degree) : degree;
747
739
  for (var _i = 0, resizeMappings_1 = resizeMappings; _i < resizeMappings_1.length; _i++) {
@@ -766,6 +758,8 @@ var Selection = /** @class */ (function () {
766
758
  parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false, value: { obj: obj } });
767
759
  sPoints = extend([], obj['selPointColl'][n].points, []);
768
760
  parent.points = extend([], parent.pointColl[n].points, []);
761
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
762
+ var ptc = parent.pointColl[n];
769
763
  parent.notify('freehand-draw', { prop: 'setPointCounter', onPropertyChange: false, value: { value: 0 } });
770
764
  var len = sPoints.length;
771
765
  for (var l = 0; l < len; l++) {
@@ -784,7 +778,7 @@ var Selection = /** @class */ (function () {
784
778
  isEntered = true;
785
779
  break;
786
780
  }
787
- else if (!this.isFhdEditing || parent.pointColl[n].isSelected) {
781
+ else if (!this.isFhdEditing || ptc.isSelected) {
788
782
  if (this.isFhdPoint || this.isFhdEditing) {
789
783
  upperContext.clearRect(0, 0, upperCanvas.width, upperCanvas.height);
790
784
  if (parent.activeObj.shape && textArea.style.display === 'none') {
@@ -792,9 +786,9 @@ var Selection = /** @class */ (function () {
792
786
  }
793
787
  }
794
788
  if (this.isFhdEditing) {
795
- var strokeColor = parent.pointColl[n].strokeColor;
789
+ var strokeColor = ptc.strokeColor;
796
790
  parent.notify('freehand-draw', { prop: 'hoverFhd', onPropertyChange: false,
797
- value: { strokeColor: strokeColor, strokeWidth: parent.pointColl[n].strokeWidth } });
791
+ value: { strokeColor: strokeColor, strokeWidth: ptc.strokeWidth } });
798
792
  }
799
793
  else {
800
794
  parent.notify('freehand-draw', { prop: 'setFreehandDrawHoveredIndex', onPropertyChange: false,
@@ -804,20 +798,17 @@ var Selection = /** @class */ (function () {
804
798
  }
805
799
  }
806
800
  else {
807
- if (x > parent.points[l].x - parent.pointColl[n].strokeWidth &&
808
- x < parent.points[l].x + parent.pointColl[n].strokeWidth &&
809
- y > parent.points[l].y - parent.pointColl[n].strokeWidth &&
810
- y < parent.points[l].y + parent.pointColl[n].strokeWidth) {
801
+ var pt = parent.points[l];
802
+ if (x > pt.x - ptc.strokeWidth && x < pt.x + ptc.strokeWidth && y > pt.y - ptc.strokeWidth &&
803
+ y < pt.y + ptc.strokeWidth) {
811
804
  this.isFhdPoint = true;
812
- parent.notify('freehand-draw', { prop: 'setFreehandDrawHoveredIndex', onPropertyChange: false,
813
- value: { index: n } });
814
- parent.notify('freehand-draw', { prop: 'hoverFhd', onPropertyChange: false,
815
- value: { strokeColor: null, strokeWidth: null } });
805
+ parent.notify('freehand-draw', { prop: 'setFreehandDrawHoveredIndex', onPropertyChange: false, value: { index: n } });
806
+ parent.notify('freehand-draw', { prop: 'hoverFhd', onPropertyChange: false, value: { strokeColor: null, strokeWidth: null } });
816
807
  upperCanvas.style.cursor = parent.cursor = 'pointer';
817
808
  isEntered = true;
818
809
  break;
819
810
  }
820
- else if (!this.isFhdEditing || parent.pointColl[n].isSelected) {
811
+ else if (!this.isFhdEditing || ptc.isSelected) {
821
812
  if (this.isFhdPoint || this.isFhdEditing) {
822
813
  upperContext.clearRect(0, 0, upperCanvas.width, upperCanvas.height);
823
814
  if (parent.activeObj.shape && textArea.style.display === 'none') {
@@ -825,9 +816,9 @@ var Selection = /** @class */ (function () {
825
816
  }
826
817
  }
827
818
  if (this.isFhdEditing) {
828
- var strokeColor = parent.pointColl[n].strokeColor;
819
+ var strokeColor = ptc.strokeColor;
829
820
  parent.notify('freehand-draw', { prop: 'hoverFhd', onPropertyChange: false,
830
- value: { strokeColor: strokeColor, strokeWidth: parent.pointColl[n].strokeWidth } });
821
+ value: { strokeColor: strokeColor, strokeWidth: ptc.strokeWidth } });
831
822
  }
832
823
  this.isFhdPoint = false;
833
824
  }
@@ -875,12 +866,14 @@ var Selection = /** @class */ (function () {
875
866
  Selection.prototype.updateActivePoint = function (x, y, isCropSelection) {
876
867
  var parent = this.parent;
877
868
  var obj = { width: 0, height: 0 };
869
+ var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
870
+ var _b = parent.activeObj.activePoint, width = _b.width, height = _b.height;
878
871
  parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
879
- value: { width: parent.activeObj.activePoint.width, height: parent.activeObj.activePoint.height, obj: obj, isImgShape: null } });
872
+ value: { width: width, height: height, obj: obj, isImgShape: null } });
880
873
  var maxDimension = obj;
881
874
  var previousShapeSettings = this.updatePrevShapeSettings();
882
- var shapeResizingArgs = { action: 'resize', previousShapeSettings: previousShapeSettings };
883
- var shapeMovingArgs = { action: 'move', previousShapeSettings: previousShapeSettings };
875
+ var shapeResizingArgs = { cancel: false, action: 'resize', previousShapeSettings: previousShapeSettings };
876
+ var shapeMovingArgs = { cancel: false, action: 'move', previousShapeSettings: previousShapeSettings };
884
877
  this.shapeResizingArgs = shapeResizingArgs;
885
878
  this.shapeMovingArgs = shapeMovingArgs;
886
879
  if (parent.activeObj.shape === 'text' && this.dragElement !== '') {
@@ -888,21 +881,21 @@ var Selection = /** @class */ (function () {
888
881
  value: { obj: parent.activeObj, isTextArea: null } });
889
882
  }
890
883
  if (this.currentDrawingShape !== '' && (this.dragElement === '' || this.dragElement === 'move')) {
891
- if (parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow' ||
892
- parent.activeObj.shape === 'path') {
884
+ var shapeColl = ['line', 'arrow', 'path'];
885
+ if (shapeColl.indexOf(parent.activeObj.shape) > -1) {
893
886
  this.dragElement = 'e-resize';
894
887
  }
895
888
  else {
896
- if (x > parent.activeObj.activePoint.startX && y > parent.activeObj.activePoint.startY) {
889
+ if (x > startX && y > startY) {
897
890
  this.dragElement = 'se-resize';
898
891
  }
899
- else if (x < parent.activeObj.activePoint.startX && y > parent.activeObj.activePoint.startY) {
892
+ else if (x < startX && y > startY) {
900
893
  this.dragElement = 'sw-resize';
901
894
  }
902
- else if (x > parent.activeObj.activePoint.startX && y < parent.activeObj.activePoint.startY) {
895
+ else if (x > startX && y < startY) {
903
896
  this.dragElement = 'ne-resize';
904
897
  }
905
- else if (x < parent.activeObj.activePoint.startX && y < parent.activeObj.activePoint.startY) {
898
+ else if (x < startX && y < startY) {
906
899
  this.dragElement = 'nw-resize';
907
900
  }
908
901
  }
@@ -918,6 +911,9 @@ var Selection = /** @class */ (function () {
918
911
  var degree;
919
912
  var isHorizontalflip = false;
920
913
  var isVerticalflip = false;
914
+ if (isCropSelection && parent.transform.straighten !== 0 && this.isMouseOutsideImg(x, y)) {
915
+ return;
916
+ }
921
917
  switch (this.dragElement.toLowerCase()) {
922
918
  case 'nw-resize':
923
919
  this.updateNWPoints(x, y, maxDimension);
@@ -968,14 +964,11 @@ var Selection = /** @class */ (function () {
968
964
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'resize');
969
965
  break;
970
966
  case 'grabbing':
971
- if (Math.atan2(x - (parent.activeObj.activePoint.startX + (parent.activeObj.activePoint.width / 2)), y - (parent.activeObj.activePoint.startY + (parent.activeObj.activePoint.height / 2))) > 0) {
972
- parent.activeObj.rotatedAngle = -Math.atan2(x - (parent.activeObj.activePoint.startX + (parent.activeObj.activePoint.width
973
- / 2)), y - (parent.activeObj.activePoint.startY + (parent.activeObj.activePoint.height / 2)));
967
+ if (Math.atan2(x - (startX + (width / 2)), y - (startY + (height / 2))) > 0) {
968
+ parent.activeObj.rotatedAngle = -Math.atan2(x - (startX + (width / 2)), y - (startY + (height / 2)));
974
969
  }
975
970
  else {
976
- parent.activeObj.rotatedAngle = Math.abs(Math.atan2(x - (parent.activeObj.activePoint.startX +
977
- (parent.activeObj.activePoint.width / 2)), y - (parent.activeObj.activePoint.startY +
978
- (parent.activeObj.activePoint.height / 2))));
971
+ parent.activeObj.rotatedAngle = Math.abs(Math.atan2(x - (startX + (width / 2)), y - (startY + (height / 2))));
979
972
  }
980
973
  if (parent.activeObj.shapeDegree === 0) {
981
974
  degree = parent.transform.degree;
@@ -1024,52 +1017,57 @@ var Selection = /** @class */ (function () {
1024
1017
  break;
1025
1018
  default:
1026
1019
  if (!isCropSelection && !parent.currObjType.isCustomCrop) {
1020
+ var activePoint = parent.activeObj.activePoint;
1027
1021
  if (this.dragPoint.startX) {
1028
- var width = (this.dragPoint.endX - this.previousPoint.x);
1029
- var height = (this.dragPoint.endY - this.previousPoint.y);
1030
- parent.activeObj.activePoint.startX += width;
1031
- parent.activeObj.activePoint.endX += width;
1032
- parent.activeObj.activePoint.startY += height;
1033
- parent.activeObj.activePoint.endY += height;
1022
+ var width_1 = (this.dragPoint.endX - this.previousPoint.x);
1023
+ var height_1 = (this.dragPoint.endY - this.previousPoint.y);
1024
+ activePoint.startX += width_1;
1025
+ activePoint.endX += width_1;
1026
+ activePoint.startY += height_1;
1027
+ activePoint.endY += height_1;
1028
+ startX = activePoint.startX;
1029
+ startY = activePoint.startY;
1030
+ endX = activePoint.endX;
1031
+ endY = activePoint.endY;
1034
1032
  if (parent.activeObj.shape !== 'line' && parent.activeObj.shape !== 'arrow' &&
1035
1033
  parent.activeObj.rotationCirclePointColl) {
1036
- parent.activeObj.rotationCirclePointColl.x += width;
1037
- parent.activeObj.rotationCirclePointColl.y += height;
1038
- parent.activeObj.rotationCirclePoint.x += width;
1039
- parent.activeObj.rotationCirclePoint.y += height;
1034
+ parent.activeObj.rotationCirclePointColl.x += width_1;
1035
+ parent.activeObj.rotationCirclePointColl.y += height_1;
1036
+ parent.activeObj.rotationCirclePoint.x += width_1;
1037
+ parent.activeObj.rotationCirclePoint.y += height_1;
1040
1038
  }
1041
1039
  if (parent.activeObj.shape === 'path') {
1042
1040
  for (var i = 0, len = parent.activeObj.pointColl.length; i < len; i++) {
1043
- parent.activeObj.pointColl[i].x += width;
1044
- parent.activeObj.pointColl[i].y += height;
1041
+ parent.activeObj.pointColl[i].x += width_1;
1042
+ parent.activeObj.pointColl[i].y += height_1;
1045
1043
  }
1046
1044
  }
1047
- if (!this.isPreventDragging && parent.activeObj.shape !== 'line' && (parent.activeObj.rotatedAngle === 0 && (parent.activeObj.activePoint.startX < parent.img.destLeft ||
1048
- parent.activeObj.activePoint.startY < parent.img.destTop || parent.activeObj.activePoint.endX >
1049
- parent.img.destLeft + parent.img.destWidth || parent.activeObj.activePoint.endY > parent.img.destTop
1045
+ if (!this.isPreventDragging && parent.activeObj.shape !== 'line' && (parent.activeObj.rotatedAngle === 0 && (startX < parent.img.destLeft ||
1046
+ startY < parent.img.destTop || endX >
1047
+ parent.img.destLeft + parent.img.destWidth || endY > parent.img.destTop
1050
1048
  + parent.img.destHeight))) {
1051
- parent.activeObj.activePoint.startX -= width;
1052
- parent.activeObj.activePoint.endX -= width;
1053
- parent.activeObj.activePoint.startY -= height;
1054
- parent.activeObj.activePoint.endY -= height;
1049
+ activePoint.startX -= width_1;
1050
+ activePoint.endX -= width_1;
1051
+ activePoint.startY -= height_1;
1052
+ activePoint.endY -= height_1;
1055
1053
  if (parent.activeObj.shape !== 'line' && parent.activeObj.shape !== 'arrow' &&
1056
1054
  parent.activeObj.rotationCirclePointColl) {
1057
- parent.activeObj.rotationCirclePointColl.x -= width;
1058
- parent.activeObj.rotationCirclePointColl.y -= height;
1059
- parent.activeObj.rotationCirclePoint.x -= width;
1060
- parent.activeObj.rotationCirclePoint.y -= height;
1055
+ parent.activeObj.rotationCirclePointColl.x -= width_1;
1056
+ parent.activeObj.rotationCirclePointColl.y -= height_1;
1057
+ parent.activeObj.rotationCirclePoint.x -= width_1;
1058
+ parent.activeObj.rotationCirclePoint.y -= height_1;
1061
1059
  }
1062
- this.setDragWidth(width);
1063
- this.setDragHeight(height);
1060
+ this.setDragWidth(width_1);
1061
+ this.setDragHeight(height_1);
1064
1062
  }
1065
1063
  }
1066
1064
  else {
1067
- parent.activeObj.activePoint.startX = x < this.mouseDownPoint.x ? x : this.mouseDownPoint.x;
1068
- parent.activeObj.activePoint.startY = y < this.mouseDownPoint.y ? y : this.mouseDownPoint.y;
1065
+ activePoint.startX = x < this.mouseDownPoint.x ? x : this.mouseDownPoint.x;
1066
+ activePoint.startY = y < this.mouseDownPoint.y ? y : this.mouseDownPoint.y;
1069
1067
  x = x < this.mouseDownPoint.x ? this.mouseDownPoint.x : x;
1070
1068
  y = y < this.mouseDownPoint.y ? this.mouseDownPoint.y : y;
1071
- parent.activeObj.activePoint.endX = x;
1072
- parent.activeObj.activePoint.endY = y;
1069
+ activePoint.endX = x;
1070
+ activePoint.endY = y;
1073
1071
  }
1074
1072
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'move');
1075
1073
  }
@@ -1078,8 +1076,9 @@ var Selection = /** @class */ (function () {
1078
1076
  };
1079
1077
  Selection.prototype.triggerShapeChange = function (shapeResizingArgs, shapeMovingArgs, type) {
1080
1078
  var parent = this.parent;
1081
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
1082
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
1079
+ var actPoint = parent.activeObj.activePoint;
1080
+ actPoint.width = actPoint.endX - actPoint.startX;
1081
+ actPoint.height = actPoint.endY - actPoint.startY;
1083
1082
  var currentShapeSettings = this.updatePrevShapeSettings();
1084
1083
  if (!isNullOrUndefined(this.shapeResizingArgs) && !isNullOrUndefined(this.shapeMovingArgs)) {
1085
1084
  shapeResizingArgs.currentShapeSettings = this.shapeResizingArgs.currentShapeSettings = currentShapeSettings;
@@ -1098,10 +1097,10 @@ var Selection = /** @class */ (function () {
1098
1097
  if (splitWords !== undefined && splitWords[0] === 'crop') {
1099
1098
  this.isCropSelection = true;
1100
1099
  }
1101
- if (!this.isCropSelection && this.parent.eventType !== 'resize' && isBlazor() && parent.events && this.parent.events.onShapeResizeStart.hasDelegate === true) {
1100
+ if (!this.isCropSelection && parent.eventType !== 'resize' && isBlazor() && parent.events && parent.events.onShapeResizeStart.hasDelegate === true) {
1102
1101
  shapeResizingArgs.action = this.currentDrawingShape !== '' ? 'drawing' : 'resize-start';
1103
1102
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1104
- parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShapeResizeStart', shapeResizingArgs).then(function (shapeResizingArgs) {
1103
+ parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShapeResizeStart', shapeResizingArgs, null).then(function (shapeResizingArgs) {
1105
1104
  parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
1106
1105
  value: { shapeSettings: shapeResizingArgs.currentShapeSettings } });
1107
1106
  });
@@ -1127,7 +1126,7 @@ var Selection = /** @class */ (function () {
1127
1126
  width: shapeResizingArgs.currentShapeSettings.width,
1128
1127
  height: shapeResizingArgs.currentShapeSettings.height } };
1129
1128
  this.selectionResizingArgs = selectionResizingArgs;
1130
- if (isBlazor() && isNullOrUndefined(this.parent.eventType) && parent.events &&
1129
+ if (isBlazor() && isNullOrUndefined(parent.eventType) && parent.events &&
1131
1130
  parent.events.onSelectionResizeStart.hasDelegate === true) {
1132
1131
  selectionResizingArgs.action = 'resize-start';
1133
1132
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
@@ -1146,7 +1145,7 @@ var Selection = /** @class */ (function () {
1146
1145
  else if (type === 'mouse-down' || type === 'mouse-up') {
1147
1146
  if (isBlazor() && parent.events && parent.events.shapeChanging.hasDelegate === true) {
1148
1147
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1149
- parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeResizingArgs).then(function (shapeResizingArgs) {
1148
+ parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeResizingArgs, null).then(function (shapeResizingArgs) {
1150
1149
  parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
1151
1150
  value: { shapeSettings: shapeResizingArgs.currentShapeSettings } });
1152
1151
  });
@@ -1158,11 +1157,11 @@ var Selection = /** @class */ (function () {
1158
1157
  }
1159
1158
  }
1160
1159
  else {
1161
- if (isBlazor() && isNullOrUndefined(this.parent.eventType) && parent.events &&
1160
+ if (isBlazor() && isNullOrUndefined(parent.eventType) && parent.events &&
1162
1161
  parent.events.onShapeDragStart.hasDelegate === true) {
1163
1162
  shapeMovingArgs.action = 'drag-start';
1164
1163
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1165
- parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShapeDragStart', shapeMovingArgs).then(function (shapeMovingArgs) {
1164
+ parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShapeDragStart', shapeMovingArgs, null).then(function (shapeMovingArgs) {
1166
1165
  parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
1167
1166
  value: { shapeSettings: shapeMovingArgs.currentShapeSettings } });
1168
1167
  });
@@ -1173,128 +1172,154 @@ var Selection = /** @class */ (function () {
1173
1172
  value: { shapeSettings: shapeMovingArgs.currentShapeSettings } });
1174
1173
  }
1175
1174
  }
1176
- this.parent.eventType = type;
1175
+ parent.eventType = type;
1177
1176
  };
1178
1177
  Selection.prototype.setDragWidth = function (width) {
1179
1178
  var parent = this.parent;
1179
+ var actPoint = parent.activeObj.activePoint;
1180
+ var _a = parent.img, destLeft = _a.destLeft, destWidth = _a.destWidth;
1180
1181
  var tempWidth = width;
1181
1182
  if (tempWidth >= 0) {
1182
1183
  for (var i = 0; i < tempWidth; i++) {
1183
1184
  width = tempWidth - i;
1184
- parent.activeObj.activePoint.startX += width;
1185
- parent.activeObj.activePoint.endX += width;
1186
- if (parent.activeObj.activePoint.startX >= parent.img.destLeft &&
1187
- parent.activeObj.activePoint.endX <= parent.img.destLeft + parent.img.destWidth) {
1185
+ actPoint.startX += width;
1186
+ actPoint.endX += width;
1187
+ if (actPoint.startX >= destLeft &&
1188
+ actPoint.endX <= destLeft + destWidth) {
1188
1189
  break;
1189
1190
  }
1190
1191
  else {
1191
- parent.activeObj.activePoint.startX -= width;
1192
- parent.activeObj.activePoint.endX -= width;
1192
+ actPoint.startX -= width;
1193
+ actPoint.endX -= width;
1193
1194
  }
1194
1195
  }
1195
1196
  }
1196
1197
  else {
1197
1198
  for (var i = 1; i < Math.abs(tempWidth); i++) {
1198
1199
  width = tempWidth + i;
1199
- parent.activeObj.activePoint.startX += width;
1200
- parent.activeObj.activePoint.endX += width;
1201
- if (parent.activeObj.activePoint.startX >= parent.img.destLeft &&
1202
- parent.activeObj.activePoint.endX <= parent.img.destLeft + parent.img.destWidth) {
1200
+ actPoint.startX += width;
1201
+ actPoint.endX += width;
1202
+ if (actPoint.startX >= destLeft &&
1203
+ actPoint.endX <= destLeft + destWidth) {
1203
1204
  break;
1204
1205
  }
1205
1206
  else {
1206
- parent.activeObj.activePoint.startX -= width;
1207
- parent.activeObj.activePoint.endX -= width;
1207
+ actPoint.startX -= width;
1208
+ actPoint.endX -= width;
1208
1209
  }
1209
1210
  }
1210
1211
  }
1211
1212
  };
1212
1213
  Selection.prototype.setDragHeight = function (height) {
1213
1214
  var parent = this.parent;
1215
+ var actPoint = parent.activeObj.activePoint;
1216
+ var _a = parent.img, destTop = _a.destTop, destHeight = _a.destHeight;
1214
1217
  var tempHeight = height;
1215
1218
  if (tempHeight >= 0) {
1216
1219
  for (var i = 1; i < tempHeight; i++) {
1217
1220
  height = tempHeight - i;
1218
- parent.activeObj.activePoint.startY += height;
1219
- parent.activeObj.activePoint.endY += height;
1220
- if (parent.activeObj.activePoint.startY >= parent.img.destTop &&
1221
- parent.activeObj.activePoint.endY <= parent.img.destTop + parent.img.destHeight) {
1221
+ actPoint.startY += height;
1222
+ actPoint.endY += height;
1223
+ if (actPoint.startY >= destTop &&
1224
+ actPoint.endY <= destTop + destHeight) {
1222
1225
  break;
1223
1226
  }
1224
1227
  else {
1225
- parent.activeObj.activePoint.startY -= height;
1226
- parent.activeObj.activePoint.endY -= height;
1228
+ actPoint.startY -= height;
1229
+ actPoint.endY -= height;
1227
1230
  }
1228
1231
  }
1229
1232
  }
1230
1233
  else {
1231
1234
  for (var i = 0; i < Math.abs(tempHeight); i++) {
1232
1235
  height = tempHeight + i;
1233
- parent.activeObj.activePoint.startY += height;
1234
- parent.activeObj.activePoint.endY += height;
1235
- if (parent.activeObj.activePoint.startY >= parent.img.destTop &&
1236
- parent.activeObj.activePoint.endY <= parent.img.destTop + parent.img.destHeight) {
1236
+ actPoint.startY += height;
1237
+ actPoint.endY += height;
1238
+ if (actPoint.startY >= destTop &&
1239
+ actPoint.endY <= destTop + destHeight) {
1237
1240
  break;
1238
1241
  }
1239
1242
  else {
1240
- parent.activeObj.activePoint.startY -= height;
1241
- parent.activeObj.activePoint.endY -= height;
1243
+ actPoint.startY -= height;
1244
+ actPoint.endY -= height;
1242
1245
  }
1243
1246
  }
1244
1247
  }
1245
1248
  };
1246
1249
  Selection.prototype.limitDrag = function (isStart) {
1250
+ var isLimiting = false;
1247
1251
  var parent = this.parent;
1248
- var startX = isStart ? parent.activeObj.activePoint.startX : parent.activeObj.activePoint.endX;
1249
- var startY = isStart ? parent.activeObj.activePoint.startY : parent.activeObj.activePoint.endY;
1250
- var endX = isStart ? parent.activeObj.activePoint.endX : parent.activeObj.activePoint.startX;
1251
- var endY = isStart ? parent.activeObj.activePoint.endY : parent.activeObj.activePoint.startY;
1252
- if (startX < parent.img.destLeft) {
1253
- startX = parent.img.destLeft;
1254
- }
1255
- if (startY < parent.img.destTop) {
1256
- startY = parent.img.destTop;
1257
- }
1258
- if (endX > parent.img.destLeft + parent.img.destWidth) {
1259
- endX = parent.img.destLeft + parent.img.destWidth;
1260
- }
1261
- if (endY > parent.img.destTop + parent.img.destHeight) {
1262
- endY = parent.img.destTop + parent.img.destHeight;
1252
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
1253
+ var actPoint = parent.activeObj.activePoint;
1254
+ var startX = isStart ? actPoint.startX : actPoint.endX;
1255
+ var startY = isStart ? actPoint.startY : actPoint.endY;
1256
+ var endX = isStart ? actPoint.endX : actPoint.startX;
1257
+ var endY = isStart ? actPoint.endY : actPoint.startY;
1258
+ if (startX < destLeft) {
1259
+ startX = destLeft;
1260
+ }
1261
+ if (startY < destTop) {
1262
+ startY = destTop;
1263
+ }
1264
+ if (endX > destLeft + destWidth) {
1265
+ endX = destLeft + destWidth;
1266
+ }
1267
+ if (endY > destTop + destHeight) {
1268
+ endY = destTop + destHeight;
1269
+ }
1270
+ if (parent.transform.straighten !== 0) {
1271
+ var obj = { isIntersect: null, arr: null };
1272
+ parent.notify('draw', { prop: 'updateImgCanvasPoints', onPropertyChange: false });
1273
+ parent.notify('draw', { prop: 'isLinesIntersect', onPropertyChange: false, value: { obj: obj } });
1274
+ if (obj['arr'][0] || obj['arr'][1] || obj['arr'][2] || obj['arr'][3]) {
1275
+ isLimiting = true;
1276
+ }
1263
1277
  }
1264
1278
  if (isStart) {
1265
- parent.activeObj.activePoint.startX = startX;
1266
- parent.activeObj.activePoint.startY = startY;
1267
- parent.activeObj.activePoint.endX = endX;
1268
- parent.activeObj.activePoint.endY = endY;
1279
+ actPoint.startX = startX;
1280
+ actPoint.startY = startY;
1281
+ actPoint.endX = endX;
1282
+ actPoint.endY = endY;
1269
1283
  }
1270
1284
  else {
1271
- parent.activeObj.activePoint.startX = endX;
1272
- parent.activeObj.activePoint.startY = endY;
1273
- parent.activeObj.activePoint.endX = startX;
1274
- parent.activeObj.activePoint.endY = startY;
1285
+ actPoint.startX = endX;
1286
+ actPoint.startY = endY;
1287
+ actPoint.endX = startX;
1288
+ actPoint.endY = startY;
1275
1289
  }
1290
+ return isLimiting;
1291
+ };
1292
+ Selection.prototype.isMouseOutsideImg = function (x, y) {
1293
+ var obj = { bool: false };
1294
+ this.parent.notify('draw', { prop: 'updateImgCanvasPoints', onPropertyChange: false });
1295
+ this.parent.notify('draw', { prop: 'isPointsInsideImg', value: { obj: obj, x: x, y: y } });
1296
+ return obj['bool'];
1276
1297
  };
1277
1298
  Selection.prototype.preventDraggingInvertly = function () {
1299
+ var isLimiting = false;
1278
1300
  var parent = this.parent;
1279
1301
  if (parent.activeObj.shape === 'image') {
1280
- return;
1302
+ return isLimiting;
1281
1303
  }
1282
1304
  if (!this.isPreventDragging && parent.activeObj.rotatedAngle === 0) {
1283
- this.limitDrag(true);
1284
- if (parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow' ||
1285
- parent.activeObj.shape === 'path') {
1286
- this.limitDrag(false);
1305
+ isLimiting = this.limitDrag(true);
1306
+ var shapeColl = ['line', 'arrow', 'path'];
1307
+ if (shapeColl.indexOf(parent.activeObj.shape) > -1) {
1308
+ isLimiting = this.limitDrag(false);
1287
1309
  }
1288
1310
  }
1311
+ return isLimiting;
1289
1312
  };
1290
1313
  Selection.prototype.preventTextDraggingInvertly = function () {
1291
1314
  var parent = this.parent;
1292
1315
  var isLimiting = false;
1316
+ var actPoint = parent.activeObj.activePoint;
1317
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
1293
1318
  if (!this.isPreventDragging) {
1294
- if (parent.activeObj.activePoint.startX < parent.img.destLeft ||
1295
- parent.activeObj.activePoint.startY < parent.img.destTop ||
1296
- parent.activeObj.activePoint.endX > parent.img.destLeft + parent.img.destWidth ||
1297
- parent.activeObj.activePoint.endY > parent.img.destTop + parent.img.destHeight) {
1319
+ if (actPoint.startX < destLeft ||
1320
+ actPoint.startY < destTop ||
1321
+ actPoint.endX > destLeft + destWidth ||
1322
+ actPoint.endY > destTop + destHeight) {
1298
1323
  isLimiting = true;
1299
1324
  }
1300
1325
  }
@@ -1302,15 +1327,16 @@ var Selection = /** @class */ (function () {
1302
1327
  };
1303
1328
  Selection.prototype.preventInverseResize = function (tempActiveObj) {
1304
1329
  var parent = this.parent;
1305
- if (parent.activeObj.activePoint.width < 0) {
1306
- parent.activeObj.activePoint.width = 0;
1307
- parent.activeObj.activePoint.startX = tempActiveObj.activePoint.startX;
1308
- parent.activeObj.activePoint.endX = tempActiveObj.activePoint.endX;
1330
+ var actPoint = parent.activeObj.activePoint;
1331
+ if (actPoint.width < 0) {
1332
+ actPoint.width = 0;
1333
+ actPoint.startX = tempActiveObj.activePoint.startX;
1334
+ actPoint.endX = tempActiveObj.activePoint.endX;
1309
1335
  }
1310
- if (parent.activeObj.activePoint.height < 0) {
1311
- parent.activeObj.activePoint.height = 0;
1312
- parent.activeObj.activePoint.startY = tempActiveObj.activePoint.startY;
1313
- parent.activeObj.activePoint.endY = tempActiveObj.activePoint.endY;
1336
+ if (actPoint.height < 0) {
1337
+ actPoint.height = 0;
1338
+ actPoint.startY = tempActiveObj.activePoint.startY;
1339
+ actPoint.endY = tempActiveObj.activePoint.endY;
1314
1340
  }
1315
1341
  };
1316
1342
  Selection.prototype.getScaleRatio = function (scale) {
@@ -1318,11 +1344,11 @@ var Selection = /** @class */ (function () {
1318
1344
  var point = { x: scale, y: scale };
1319
1345
  if (parent.activeObj.shape && parent.activeObj.shape !== 'crop-custom' &&
1320
1346
  parent.activeObj.shape !== 'crop-circle' && parent.activeObj.shape !== 'crop-square') {
1321
- var ratio = parent.activeObj.shape === 'image' ?
1347
+ var ratio = parent.activeObj.shape === 'image' || parent.activeObj.shape === 'text' ?
1322
1348
  this.findImageRatio(parent.activeObj.activePoint.width, parent.activeObj.activePoint.height).split('-') :
1323
1349
  parent.activeObj.shape.split('-');
1324
- if (ratio.length > 1 || parent.activeObj.shape === 'image') {
1325
- ratio = parent.activeObj.shape === 'image' ? ratio[0].split(':') : ratio[1].split(':');
1350
+ if (ratio.length > 1 || parent.activeObj.shape === 'image' || parent.activeObj.shape === 'text') {
1351
+ ratio = parent.activeObj.shape === 'image' || parent.activeObj.shape === 'text' ? ratio[0].split(':') : ratio[1].split(':');
1326
1352
  var newScale = scale / (parseInt(ratio[1], 10));
1327
1353
  point.x = newScale * (parseInt(ratio[0], 10));
1328
1354
  point.y = newScale * (parseInt(ratio[1], 10));
@@ -1345,42 +1371,25 @@ var Selection = /** @class */ (function () {
1345
1371
  }
1346
1372
  return ratio;
1347
1373
  };
1374
+ Selection.prototype.revertResizing = function (tempActiveObj) {
1375
+ var parent = this.parent;
1376
+ var actPoint = parent.activeObj.activePoint;
1377
+ if (this.preventDraggingInvertly()) {
1378
+ actPoint.startX = tempActiveObj.activePoint.startX;
1379
+ actPoint.startY = tempActiveObj.activePoint.startY;
1380
+ actPoint.endX = tempActiveObj.activePoint.endX;
1381
+ actPoint.endY = tempActiveObj.activePoint.endY;
1382
+ }
1383
+ };
1348
1384
  Selection.prototype.updateNWPoints = function (x, y, maxDimension) {
1349
1385
  var parent = this.parent;
1350
- var diff;
1386
+ var actPoint = parent.activeObj.activePoint;
1351
1387
  var width;
1352
1388
  var height;
1353
1389
  var scale;
1354
- var percentage;
1355
- var prevDiffX = this.diffPoint.x;
1356
- var prevDiffY = this.diffPoint.y;
1357
1390
  var tempActiveObj = extend({}, parent.activeObj, null, true);
1358
1391
  if (parent.activeObj.shape === 'text') {
1359
- if (this.oldPoint.x === undefined && this.oldPoint.y === undefined) {
1360
- this.diffPoint.x = parent.activeObj.activePoint.startX - x;
1361
- this.diffPoint.y = parent.activeObj.activePoint.startY - y;
1362
- }
1363
- else {
1364
- this.diffPoint.x = this.oldPoint.x - x;
1365
- this.diffPoint.y = this.oldPoint.y - y;
1366
- }
1367
- this.oldPoint.x = x;
1368
- this.oldPoint.y = y;
1369
- if (this.diffPoint.x <= prevDiffX && this.diffPoint.y >= prevDiffY) {
1370
- diff = Math.min(this.diffPoint.x, this.diffPoint.y);
1371
- }
1372
- else {
1373
- diff = Math.max(this.diffPoint.x, this.diffPoint.y);
1374
- }
1375
- percentage = (diff / 10);
1376
- parent.activeObj.activePoint.startX -= (maxDimension.width / 100) * percentage;
1377
- parent.activeObj.activePoint.startY -= (maxDimension.height / 100) * percentage;
1378
- if (this.preventTextDraggingInvertly()) {
1379
- parent.activeObj.activePoint.startX += (maxDimension.width / 100) * percentage;
1380
- parent.activeObj.activePoint.startY += (maxDimension.height / 100) * percentage;
1381
- }
1382
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
1383
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
1392
+ this.resizeImg(x, y, 'nw-resize', tempActiveObj);
1384
1393
  parent.notify('shape', { prop: 'updateFontSize', onPropertyChange: false,
1385
1394
  value: { obj: parent.activeObj } });
1386
1395
  }
@@ -1394,62 +1403,68 @@ var Selection = /** @class */ (function () {
1394
1403
  this.resizeImg(x, y, 'nw-resize', tempActiveObj);
1395
1404
  }
1396
1405
  else {
1397
- this.adjustNWPoints(parent.activeObj.activePoint, x, y, parent.activeObj.rotatedAngle);
1406
+ this.adjustNWPoints(actPoint, x, y, parent.activeObj.rotatedAngle);
1398
1407
  }
1399
- if (parent.activeObj.activePoint.startX > parent.activeObj.activePoint.endX) {
1400
- var temp = parent.activeObj.activePoint.startX;
1401
- parent.activeObj.activePoint.startX = parent.activeObj.activePoint.endX;
1402
- parent.activeObj.activePoint.endX = temp;
1408
+ if (actPoint.startX > actPoint.endX) {
1409
+ var temp = actPoint.startX;
1410
+ actPoint.startX = actPoint.endX;
1411
+ actPoint.endX = temp;
1403
1412
  this.dragElement = parent.upperCanvas.style.cursor = parent.cursor = 'ne-resize';
1404
1413
  }
1405
- if (parent.activeObj.activePoint.startY > parent.activeObj.activePoint.endY) {
1406
- var temp = parent.activeObj.activePoint.startY;
1407
- parent.activeObj.activePoint.startY = parent.activeObj.activePoint.endY;
1408
- parent.activeObj.activePoint.endY = temp;
1414
+ if (actPoint.startY > actPoint.endY) {
1415
+ var temp = actPoint.startY;
1416
+ actPoint.startY = actPoint.endY;
1417
+ actPoint.endY = temp;
1409
1418
  this.dragElement = parent.upperCanvas.style.cursor = parent.cursor = 'sw-resize';
1410
1419
  }
1411
- this.preventDraggingInvertly();
1420
+ this.revertResizing(tempActiveObj);
1412
1421
  }
1413
1422
  else {
1414
- if (parent.activeObj.activePoint.startX < x && parent.activeObj.activePoint.startY < y) {
1415
- width = x - parent.activeObj.activePoint.startX;
1416
- height = y - parent.activeObj.activePoint.startY;
1423
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
1424
+ if (actPoint.startX < x && actPoint.startY < y) {
1425
+ width = x - actPoint.startX;
1426
+ height = y - actPoint.startY;
1417
1427
  scale = Math.min(width, height);
1418
1428
  var newScale = this.getScaleRatio(scale);
1419
- parent.activeObj.activePoint.startX += newScale.x;
1420
- parent.activeObj.activePoint.startY += newScale.y;
1421
- var left = parent.img.destLeft > 0 ? parent.img.destLeft : 0;
1422
- var top_1 = parent.img.destTop > 0 ? parent.img.destTop : 0;
1423
- if (parent.activeObj.activePoint.startX < left || parent.activeObj.activePoint.startY < top_1) {
1424
- parent.activeObj.activePoint.startX -= newScale.x;
1425
- parent.activeObj.activePoint.startY -= newScale.y;
1429
+ actPoint.startX += newScale.x;
1430
+ actPoint.startY += newScale.y;
1431
+ var left = destLeft > 0 ? destLeft : 0;
1432
+ var top_1 = destTop > 0 ? destTop : 0;
1433
+ if (actPoint.startX < left || actPoint.startY < top_1) {
1434
+ actPoint.startX -= newScale.x;
1435
+ actPoint.startY -= newScale.y;
1426
1436
  }
1427
1437
  }
1428
1438
  else {
1429
- width = parent.activeObj.activePoint.startX - x;
1430
- height = y - parent.activeObj.activePoint.endY;
1439
+ width = actPoint.startX - x;
1440
+ height = y - actPoint.endY;
1431
1441
  scale = Math.max(width, height);
1432
1442
  var newScale = this.getScaleRatio(scale);
1433
- parent.activeObj.activePoint.startX -= newScale.x;
1434
- parent.activeObj.activePoint.startY -= newScale.y;
1435
- var left = parent.img.destLeft > 0 ? parent.img.destLeft : 0;
1436
- var top_2 = parent.img.destTop > 0 ? parent.img.destTop : 0;
1437
- if (parent.activeObj.activePoint.startX < left || parent.activeObj.activePoint.startY < top_2) {
1438
- parent.activeObj.activePoint.startX += newScale.x;
1439
- parent.activeObj.activePoint.startY += newScale.y;
1443
+ actPoint.startX -= newScale.x;
1444
+ actPoint.startY -= newScale.y;
1445
+ var left = destLeft > 0 ? destLeft : 0;
1446
+ var top_2 = destTop > 0 ? destTop : 0;
1447
+ if (actPoint.startX < left || actPoint.startY < top_2) {
1448
+ actPoint.startX += newScale.x;
1449
+ actPoint.startY += newScale.y;
1440
1450
  }
1441
1451
  }
1452
+ actPoint.width = actPoint.endX - actPoint.startX;
1453
+ actPoint.height = actPoint.endY - actPoint.startY;
1454
+ this.revertResizing(tempActiveObj);
1442
1455
  }
1443
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
1444
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
1456
+ actPoint.width = actPoint.endX - actPoint.startX;
1457
+ actPoint.height = actPoint.endY - actPoint.startY;
1445
1458
  this.preventInverseResize(tempActiveObj);
1446
1459
  }
1447
1460
  };
1448
1461
  Selection.prototype.updateNPoints = function (x, y) {
1449
1462
  var parent = this.parent;
1463
+ var actPoint = parent.activeObj.activePoint;
1450
1464
  var width;
1451
1465
  var height;
1452
1466
  var scale;
1467
+ var tempActiveObj = extend({}, parent.activeObj, null, true);
1453
1468
  if (parent.activeObj.shape !== 'text') {
1454
1469
  var splitWords = void 0;
1455
1470
  if (parent.activeObj.shape) {
@@ -1466,88 +1481,63 @@ var Selection = /** @class */ (function () {
1466
1481
  }
1467
1482
  width = (this.dragPoint.endX - this.previousPoint.x);
1468
1483
  height = (this.dragPoint.endY - this.previousPoint.y);
1469
- this.adjustRotationPoints(parent.activeObj.activePoint, width, height, parent.activeObj.rotatedAngle);
1484
+ this.adjustRotationPoints(actPoint, width, height, parent.activeObj.rotatedAngle);
1470
1485
  }
1471
1486
  else {
1472
- parent.activeObj.activePoint.startY = y;
1473
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
1487
+ actPoint.startY = y;
1488
+ actPoint.height = actPoint.endY - actPoint.startY;
1474
1489
  }
1475
- if (parent.activeObj.activePoint.startY > parent.activeObj.activePoint.endY) {
1476
- var temp = parent.activeObj.activePoint.startY;
1477
- parent.activeObj.activePoint.startY = parent.activeObj.activePoint.endY;
1478
- parent.activeObj.activePoint.endY = temp;
1490
+ if (actPoint.startY > actPoint.endY) {
1491
+ var temp = actPoint.startY;
1492
+ actPoint.startY = actPoint.endY;
1493
+ actPoint.endY = temp;
1479
1494
  this.dragElement = this.resizedElement = 's-resize';
1480
1495
  }
1481
- this.preventDraggingInvertly();
1496
+ this.revertResizing(tempActiveObj);
1482
1497
  }
1483
1498
  else {
1484
- if (parent.activeObj.activePoint.endX > x && parent.activeObj.activePoint.startY < y) {
1485
- width = parent.activeObj.activePoint.endX - x;
1486
- height = y - parent.activeObj.activePoint.startY;
1499
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
1500
+ if (actPoint.endX > x && actPoint.startY < y) {
1501
+ width = actPoint.endX - x;
1502
+ height = y - actPoint.startY;
1487
1503
  scale = Math.min(width, height);
1488
1504
  var newScale = this.getScaleRatio(scale);
1489
- parent.activeObj.activePoint.endX -= newScale.x;
1490
- parent.activeObj.activePoint.startY += newScale.y;
1491
- if (parent.activeObj.activePoint.endX > (parent.img.destLeft + parent.img.destWidth) ||
1492
- parent.activeObj.activePoint.startY < parent.img.destTop) {
1493
- parent.activeObj.activePoint.endX += newScale.x;
1494
- parent.activeObj.activePoint.startY -= newScale.y;
1505
+ actPoint.endX -= newScale.x;
1506
+ actPoint.startY += newScale.y;
1507
+ if (actPoint.endX > (destLeft + destWidth) ||
1508
+ actPoint.startY < destTop) {
1509
+ actPoint.endX += newScale.x;
1510
+ actPoint.startY -= newScale.y;
1495
1511
  }
1496
1512
  }
1497
1513
  else {
1498
- width = x - parent.activeObj.activePoint.endX;
1499
- height = parent.activeObj.activePoint.startY - y;
1514
+ width = x - actPoint.endX;
1515
+ height = actPoint.startY - y;
1500
1516
  scale = Math.max(width, height);
1501
1517
  var newScale = this.getScaleRatio(scale);
1502
- parent.activeObj.activePoint.endX += newScale.x;
1503
- parent.activeObj.activePoint.startY -= newScale.y;
1504
- if (parent.activeObj.activePoint.endX > (parent.img.destLeft + parent.img.destWidth) ||
1505
- parent.activeObj.activePoint.startY < parent.img.destTop) {
1506
- parent.activeObj.activePoint.endX -= newScale.x;
1507
- parent.activeObj.activePoint.startY += newScale.y;
1518
+ actPoint.endX += newScale.x;
1519
+ actPoint.startY -= newScale.y;
1520
+ if (actPoint.endX > (destLeft + destWidth) ||
1521
+ actPoint.startY < destTop) {
1522
+ actPoint.endX -= newScale.x;
1523
+ actPoint.startY += newScale.y;
1508
1524
  }
1509
1525
  }
1510
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
1511
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
1526
+ actPoint.width = actPoint.endX - actPoint.startX;
1527
+ actPoint.height = actPoint.endY - actPoint.startY;
1528
+ this.revertResizing(tempActiveObj);
1512
1529
  }
1513
1530
  }
1514
1531
  };
1515
1532
  Selection.prototype.updateNEPoints = function (x, y, maxDimension) {
1516
1533
  var parent = this.parent;
1517
- var diff;
1534
+ var actPoint = parent.activeObj.activePoint;
1518
1535
  var width;
1519
1536
  var height;
1520
1537
  var scale;
1521
- var percentage;
1522
- var prevDiffX = this.diffPoint.x;
1523
- var prevDiffY = this.diffPoint.y;
1524
1538
  var tempActiveObj = extend({}, parent.activeObj, null, true);
1525
1539
  if (parent.activeObj.shape === 'text') {
1526
- if (this.oldPoint.x === undefined && this.oldPoint.y === undefined) {
1527
- this.diffPoint.x = x - parent.activeObj.activePoint.endX;
1528
- this.diffPoint.y = parent.activeObj.activePoint.startY - y;
1529
- }
1530
- else {
1531
- this.diffPoint.x = x - this.oldPoint.x;
1532
- this.diffPoint.y = this.oldPoint.y - y;
1533
- }
1534
- this.oldPoint.x = x;
1535
- this.oldPoint.y = y;
1536
- if (this.diffPoint.x <= prevDiffX && this.diffPoint.y >= prevDiffY) {
1537
- diff = Math.min(this.diffPoint.x, this.diffPoint.y);
1538
- }
1539
- else {
1540
- diff = Math.max(this.diffPoint.x, this.diffPoint.y);
1541
- }
1542
- percentage = (diff / 10);
1543
- parent.activeObj.activePoint.endX += (maxDimension.width / 100) * percentage;
1544
- parent.activeObj.activePoint.startY -= (maxDimension.height / 100) * percentage;
1545
- if (this.preventTextDraggingInvertly()) {
1546
- parent.activeObj.activePoint.endX -= (maxDimension.width / 100) * percentage;
1547
- parent.activeObj.activePoint.startY += (maxDimension.height / 100) * percentage;
1548
- }
1549
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
1550
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
1540
+ this.resizeImg(x, y, 'ne-resize', tempActiveObj);
1551
1541
  parent.notify('shape', { prop: 'updateFontSize', onPropertyChange: false,
1552
1542
  value: { obj: parent.activeObj } });
1553
1543
  }
@@ -1561,64 +1551,70 @@ var Selection = /** @class */ (function () {
1561
1551
  this.resizeImg(x, y, 'ne-resize', tempActiveObj);
1562
1552
  }
1563
1553
  else {
1564
- this.adjustNEPoints(parent.activeObj.activePoint, x, y, parent.activeObj.rotatedAngle);
1554
+ this.adjustNEPoints(actPoint, x, y, parent.activeObj.rotatedAngle);
1565
1555
  }
1566
- if (parent.activeObj.activePoint.endX < parent.activeObj.activePoint.startX) {
1567
- var temp = parent.activeObj.activePoint.endX;
1568
- parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX;
1569
- parent.activeObj.activePoint.startX = temp;
1556
+ if (actPoint.endX < actPoint.startX) {
1557
+ var temp = actPoint.endX;
1558
+ actPoint.endX = actPoint.startX;
1559
+ actPoint.startX = temp;
1570
1560
  this.dragElement = parent.upperCanvas.style.cursor = parent.cursor = 'nw-resize';
1571
1561
  }
1572
- if (parent.activeObj.activePoint.startY > parent.activeObj.activePoint.endY) {
1573
- var temp = parent.activeObj.activePoint.startY;
1574
- parent.activeObj.activePoint.startY = parent.activeObj.activePoint.endY;
1575
- parent.activeObj.activePoint.endY = temp;
1562
+ if (actPoint.startY > actPoint.endY) {
1563
+ var temp = actPoint.startY;
1564
+ actPoint.startY = actPoint.endY;
1565
+ actPoint.endY = temp;
1576
1566
  this.dragElement = parent.upperCanvas.style.cursor = parent.cursor = 'se-resize';
1577
1567
  }
1578
- this.preventDraggingInvertly();
1568
+ this.revertResizing(tempActiveObj);
1579
1569
  }
1580
1570
  else {
1581
- if (parent.activeObj.activePoint.endX > x && parent.activeObj.activePoint.startY < y) {
1582
- width = parent.activeObj.activePoint.endX - x;
1583
- height = y - parent.activeObj.activePoint.startY;
1571
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
1572
+ if (actPoint.endX > x && actPoint.startY < y) {
1573
+ width = actPoint.endX - x;
1574
+ height = y - actPoint.startY;
1584
1575
  scale = Math.min(width, height);
1585
1576
  var newScale = this.getScaleRatio(scale);
1586
- parent.activeObj.activePoint.endX -= newScale.x;
1587
- parent.activeObj.activePoint.startY += newScale.y;
1588
- var endX = parent.img.destLeft + parent.img.destWidth < parent.lowerCanvas.width ?
1589
- parent.img.destLeft + parent.img.destWidth : parent.lowerCanvas.width;
1590
- var endY = parent.img.destTop > 0 ? parent.img.destTop : 0;
1591
- if (parent.activeObj.activePoint.endX > endX || parent.activeObj.activePoint.startY < endY) {
1592
- parent.activeObj.activePoint.endX += newScale.x;
1593
- parent.activeObj.activePoint.startY -= newScale.y;
1577
+ actPoint.endX -= newScale.x;
1578
+ actPoint.startY += newScale.y;
1579
+ var endX = destLeft + destWidth < parent.lowerCanvas.width ?
1580
+ destLeft + destWidth : parent.lowerCanvas.width;
1581
+ var endY = destTop > 0 ? destTop : 0;
1582
+ if (actPoint.endX > endX || actPoint.startY < endY) {
1583
+ actPoint.endX += newScale.x;
1584
+ actPoint.startY -= newScale.y;
1594
1585
  }
1595
1586
  }
1596
1587
  else {
1597
- width = x - parent.activeObj.activePoint.endX;
1598
- height = parent.activeObj.activePoint.startY - y;
1588
+ width = x - actPoint.endX;
1589
+ height = actPoint.startY - y;
1599
1590
  scale = Math.max(width, height);
1600
1591
  var newScale = this.getScaleRatio(scale);
1601
- parent.activeObj.activePoint.endX += newScale.x;
1602
- parent.activeObj.activePoint.startY -= newScale.y;
1603
- var endX = parent.img.destLeft + parent.img.destWidth < parent.lowerCanvas.width ?
1604
- parent.img.destLeft + parent.img.destWidth : parent.lowerCanvas.width;
1605
- var endY = parent.img.destTop > 0 ? parent.img.destTop : 0;
1606
- if (parent.activeObj.activePoint.endX > endX || parent.activeObj.activePoint.startY < endY) {
1607
- parent.activeObj.activePoint.endX -= newScale.x;
1608
- parent.activeObj.activePoint.startY += newScale.y;
1592
+ actPoint.endX += newScale.x;
1593
+ actPoint.startY -= newScale.y;
1594
+ var endX = destLeft + destWidth < parent.lowerCanvas.width ?
1595
+ destLeft + destWidth : parent.lowerCanvas.width;
1596
+ var endY = destTop > 0 ? destTop : 0;
1597
+ if (actPoint.endX > endX || actPoint.startY < endY) {
1598
+ actPoint.endX -= newScale.x;
1599
+ actPoint.startY += newScale.y;
1609
1600
  }
1610
1601
  }
1602
+ actPoint.width = actPoint.endX - actPoint.startX;
1603
+ actPoint.height = actPoint.endY - actPoint.startY;
1604
+ this.revertResizing(tempActiveObj);
1611
1605
  }
1612
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
1613
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
1606
+ actPoint.width = actPoint.endX - actPoint.startX;
1607
+ actPoint.height = actPoint.endY - actPoint.startY;
1614
1608
  this.preventInverseResize(tempActiveObj);
1615
1609
  }
1616
1610
  };
1617
1611
  Selection.prototype.updateWPoints = function (x, y) {
1618
1612
  var parent = this.parent;
1613
+ var actPoint = parent.activeObj.activePoint;
1619
1614
  var width;
1620
1615
  var height;
1621
1616
  var scale;
1617
+ var tempActiveObj = extend({}, parent.activeObj, null, true);
1622
1618
  if (parent.activeObj.shape !== 'text') {
1623
1619
  var splitWords = void 0;
1624
1620
  if (parent.activeObj.shape) {
@@ -1635,15 +1631,15 @@ var Selection = /** @class */ (function () {
1635
1631
  }
1636
1632
  width = (this.dragPoint.endX - this.previousPoint.x);
1637
1633
  height = (this.dragPoint.endY - this.previousPoint.y);
1638
- this.adjustRotationPoints(parent.activeObj.activePoint, width, height, parent.activeObj.rotatedAngle);
1634
+ this.adjustRotationPoints(actPoint, width, height, parent.activeObj.rotatedAngle);
1639
1635
  }
1640
1636
  else {
1641
- parent.activeObj.activePoint.startX = x;
1642
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
1637
+ actPoint.startX = x;
1638
+ actPoint.width = actPoint.endX - actPoint.startX;
1643
1639
  }
1644
1640
  if (parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow' || parent.activeObj.shape === 'path') {
1645
- parent.activeObj.activePoint.startY = y;
1646
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
1641
+ actPoint.startY = y;
1642
+ actPoint.height = actPoint.endY - actPoint.startY;
1647
1643
  if (this.adjustActObjForLineArrow()) {
1648
1644
  this.dragElement = 'e-resize';
1649
1645
  if (parent.activeObj.triangleDirection === 'right') {
@@ -1654,51 +1650,55 @@ var Selection = /** @class */ (function () {
1654
1650
  }
1655
1651
  }
1656
1652
  }
1657
- else if (parent.activeObj.activePoint.startX > parent.activeObj.activePoint.endX) {
1658
- var temp = parent.activeObj.activePoint.startX;
1659
- parent.activeObj.activePoint.startX = parent.activeObj.activePoint.endX;
1660
- parent.activeObj.activePoint.endX = temp;
1653
+ else if (actPoint.startX > actPoint.endX) {
1654
+ var temp = actPoint.startX;
1655
+ actPoint.startX = actPoint.endX;
1656
+ actPoint.endX = temp;
1661
1657
  this.dragElement = this.resizedElement = 'e-resize';
1662
1658
  }
1663
- this.preventDraggingInvertly();
1659
+ this.revertResizing(tempActiveObj);
1664
1660
  }
1665
1661
  else {
1666
- if (parent.activeObj.activePoint.startX < x && parent.activeObj.activePoint.endY > y) {
1667
- width = x - parent.activeObj.activePoint.startX;
1668
- height = parent.activeObj.activePoint.endY - y;
1662
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
1663
+ if (actPoint.startX < x && actPoint.endY > y) {
1664
+ width = x - actPoint.startX;
1665
+ height = actPoint.endY - y;
1669
1666
  scale = Math.min(width, height);
1670
1667
  var newScale = this.getScaleRatio(scale);
1671
- parent.activeObj.activePoint.startX += newScale.x;
1672
- parent.activeObj.activePoint.endY -= newScale.y;
1673
- if (parent.activeObj.activePoint.startX < parent.img.destLeft || parent.activeObj.activePoint.endY >
1674
- (parent.img.destTop + parent.img.destHeight)) {
1675
- parent.activeObj.activePoint.startX -= newScale.x;
1676
- parent.activeObj.activePoint.endY += newScale.y;
1668
+ actPoint.startX += newScale.x;
1669
+ actPoint.endY -= newScale.y;
1670
+ if (actPoint.startX < destLeft || actPoint.endY >
1671
+ (destTop + destHeight)) {
1672
+ actPoint.startX -= newScale.x;
1673
+ actPoint.endY += newScale.y;
1677
1674
  }
1678
1675
  }
1679
1676
  else {
1680
- width = parent.activeObj.activePoint.startX - x;
1681
- height = y - parent.activeObj.activePoint.endY;
1677
+ width = actPoint.startX - x;
1678
+ height = y - actPoint.endY;
1682
1679
  scale = Math.max(width, height);
1683
1680
  var newScale = this.getScaleRatio(scale);
1684
- parent.activeObj.activePoint.startX -= newScale.x;
1685
- parent.activeObj.activePoint.endY += newScale.y;
1686
- if (parent.activeObj.activePoint.startX < parent.img.destLeft || parent.activeObj.activePoint.endY >
1687
- (parent.img.destTop + parent.img.destHeight)) {
1688
- parent.activeObj.activePoint.startX += newScale.x;
1689
- parent.activeObj.activePoint.endY -= newScale.y;
1681
+ actPoint.startX -= newScale.x;
1682
+ actPoint.endY += newScale.y;
1683
+ if (actPoint.startX < destLeft || actPoint.endY >
1684
+ (destTop + destHeight)) {
1685
+ actPoint.startX += newScale.x;
1686
+ actPoint.endY -= newScale.y;
1690
1687
  }
1691
1688
  }
1692
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
1693
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
1689
+ actPoint.width = actPoint.endX - actPoint.startX;
1690
+ actPoint.height = actPoint.endY - actPoint.startY;
1691
+ this.revertResizing(tempActiveObj);
1694
1692
  }
1695
1693
  }
1696
1694
  };
1697
1695
  Selection.prototype.updateEPoints = function (x, y) {
1698
1696
  var parent = this.parent;
1697
+ var actPoint = parent.activeObj.activePoint;
1699
1698
  var width;
1700
1699
  var height;
1701
1700
  var scale;
1701
+ var tempActiveObj = extend({}, parent.activeObj, null, true);
1702
1702
  if (parent.activeObj.shape !== 'text') {
1703
1703
  var splitWords = void 0;
1704
1704
  if (parent.activeObj.shape) {
@@ -1715,15 +1715,15 @@ var Selection = /** @class */ (function () {
1715
1715
  }
1716
1716
  width = (this.dragPoint.endX - this.previousPoint.x);
1717
1717
  height = (this.dragPoint.endY - this.previousPoint.y);
1718
- this.adjustRotationPoints(parent.activeObj.activePoint, width, height, parent.activeObj.rotatedAngle);
1718
+ this.adjustRotationPoints(actPoint, width, height, parent.activeObj.rotatedAngle);
1719
1719
  }
1720
1720
  else {
1721
- parent.activeObj.activePoint.endX = x;
1722
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
1721
+ actPoint.endX = x;
1722
+ actPoint.width = actPoint.endX - actPoint.startX;
1723
1723
  }
1724
1724
  if (parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow' || parent.activeObj.shape === 'path') {
1725
- parent.activeObj.activePoint.endY = y;
1726
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
1725
+ actPoint.endY = y;
1726
+ actPoint.height = actPoint.endY - actPoint.startY;
1727
1727
  if (this.adjustActObjForLineArrow()) {
1728
1728
  this.dragElement = 'w-resize';
1729
1729
  if (parent.activeObj.triangleDirection === 'right') {
@@ -1734,82 +1734,57 @@ var Selection = /** @class */ (function () {
1734
1734
  }
1735
1735
  }
1736
1736
  }
1737
- else if (parent.activeObj.activePoint.endX < parent.activeObj.activePoint.startX) {
1738
- var temp = parent.activeObj.activePoint.endX;
1739
- parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX;
1740
- parent.activeObj.activePoint.startX = temp;
1737
+ else if (actPoint.endX < actPoint.startX) {
1738
+ var temp = actPoint.endX;
1739
+ actPoint.endX = actPoint.startX;
1740
+ actPoint.startX = temp;
1741
1741
  this.dragElement = this.resizedElement = 'w-resize';
1742
1742
  }
1743
- this.preventDraggingInvertly();
1743
+ this.revertResizing(tempActiveObj);
1744
1744
  }
1745
1745
  else {
1746
- if (parent.activeObj.activePoint.endX > x && parent.activeObj.activePoint.endY > y) {
1747
- width = parent.activeObj.activePoint.endX - x;
1748
- height = parent.activeObj.activePoint.endY - y;
1746
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
1747
+ if (actPoint.endX > x && actPoint.endY > y) {
1748
+ width = actPoint.endX - x;
1749
+ height = actPoint.endY - y;
1749
1750
  scale = Math.min(width, height);
1750
1751
  var newScale = this.getScaleRatio(scale);
1751
- parent.activeObj.activePoint.endX -= newScale.x;
1752
- parent.activeObj.activePoint.endY -= newScale.y;
1753
- if (parent.activeObj.activePoint.endX > (parent.img.destLeft + parent.img.destWidth) ||
1754
- parent.activeObj.activePoint.endY > (parent.img.destTop + parent.img.destHeight)) {
1755
- parent.activeObj.activePoint.endX += newScale.x;
1756
- parent.activeObj.activePoint.endY += newScale.y;
1752
+ actPoint.endX -= newScale.x;
1753
+ actPoint.endY -= newScale.y;
1754
+ if (actPoint.endX > (destLeft + destWidth) ||
1755
+ actPoint.endY > (destTop + destHeight)) {
1756
+ actPoint.endX += newScale.x;
1757
+ actPoint.endY += newScale.y;
1757
1758
  }
1758
1759
  }
1759
1760
  else {
1760
- width = x - parent.activeObj.activePoint.endX;
1761
- height = y - parent.activeObj.activePoint.endY;
1761
+ width = x - actPoint.endX;
1762
+ height = y - actPoint.endY;
1762
1763
  scale = Math.max(width, height);
1763
1764
  var newScale = this.getScaleRatio(scale);
1764
- parent.activeObj.activePoint.endX += newScale.x;
1765
- parent.activeObj.activePoint.endY += newScale.y;
1766
- if (parent.activeObj.activePoint.endX > (parent.img.destLeft + parent.img.destWidth) ||
1767
- parent.activeObj.activePoint.endY > (parent.img.destTop + parent.img.destHeight)) {
1768
- parent.activeObj.activePoint.endX -= newScale.x;
1769
- parent.activeObj.activePoint.endY -= newScale.y;
1765
+ actPoint.endX += newScale.x;
1766
+ actPoint.endY += newScale.y;
1767
+ if (actPoint.endX > (destLeft + destWidth) ||
1768
+ actPoint.endY > (destTop + destHeight)) {
1769
+ actPoint.endX -= newScale.x;
1770
+ actPoint.endY -= newScale.y;
1770
1771
  }
1771
1772
  }
1772
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
1773
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
1773
+ actPoint.width = actPoint.endX - actPoint.startX;
1774
+ actPoint.height = actPoint.endY - actPoint.startY;
1775
+ this.revertResizing(tempActiveObj);
1774
1776
  }
1775
1777
  }
1776
1778
  };
1777
1779
  Selection.prototype.updateSWPoints = function (x, y, maxDimension) {
1778
1780
  var parent = this.parent;
1779
- var diff;
1781
+ var actPoint = parent.activeObj.activePoint;
1780
1782
  var width;
1781
1783
  var height;
1782
1784
  var scale;
1783
- var percentage;
1784
- var prevDiffX = this.diffPoint.x;
1785
- var prevDiffY = this.diffPoint.y;
1786
1785
  var tempActiveObj = extend({}, parent.activeObj, null, true);
1787
1786
  if (parent.activeObj.shape === 'text') {
1788
- if (isNullOrUndefined(this.oldPoint.x) && isNullOrUndefined(this.oldPoint.y)) {
1789
- this.diffPoint.x = parent.activeObj.activePoint.startX - x;
1790
- this.diffPoint.y = y - parent.activeObj.activePoint.endY;
1791
- }
1792
- else {
1793
- this.diffPoint.x = this.oldPoint.x - x;
1794
- this.diffPoint.y = y - this.oldPoint.y;
1795
- }
1796
- this.oldPoint.x = x;
1797
- this.oldPoint.y = y;
1798
- if (this.diffPoint.x <= prevDiffX && this.diffPoint.y >= prevDiffY) {
1799
- diff = Math.min(this.diffPoint.x, this.diffPoint.y);
1800
- }
1801
- else {
1802
- diff = Math.max(this.diffPoint.x, this.diffPoint.y);
1803
- }
1804
- percentage = (diff / 10);
1805
- parent.activeObj.activePoint.startX -= (maxDimension.width / 100) * percentage;
1806
- parent.activeObj.activePoint.endY += (maxDimension.height / 100) * percentage;
1807
- if (this.preventTextDraggingInvertly()) {
1808
- parent.activeObj.activePoint.startX += (maxDimension.width / 100) * percentage;
1809
- parent.activeObj.activePoint.endY -= (maxDimension.height / 100) * percentage;
1810
- }
1811
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
1812
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
1787
+ this.resizeImg(x, y, 'sw-resize', tempActiveObj);
1813
1788
  parent.notify('shape', { prop: 'updateFontSize', onPropertyChange: false,
1814
1789
  value: { obj: parent.activeObj } });
1815
1790
  }
@@ -1823,64 +1798,70 @@ var Selection = /** @class */ (function () {
1823
1798
  this.resizeImg(x, y, 'sw-resize', tempActiveObj);
1824
1799
  }
1825
1800
  else {
1826
- this.adjustSWPoints(parent.activeObj.activePoint, x, y, parent.activeObj.rotatedAngle);
1801
+ this.adjustSWPoints(actPoint, x, y, parent.activeObj.rotatedAngle);
1827
1802
  }
1828
- if (parent.activeObj.activePoint.startX > parent.activeObj.activePoint.endX) {
1829
- var temp = parent.activeObj.activePoint.startX;
1830
- parent.activeObj.activePoint.startX = parent.activeObj.activePoint.endX;
1831
- parent.activeObj.activePoint.endX = temp;
1803
+ if (actPoint.startX > actPoint.endX) {
1804
+ var temp = actPoint.startX;
1805
+ actPoint.startX = actPoint.endX;
1806
+ actPoint.endX = temp;
1832
1807
  this.dragElement = parent.upperCanvas.style.cursor = parent.cursor = 'se-resize';
1833
1808
  }
1834
- if (parent.activeObj.activePoint.endY < parent.activeObj.activePoint.startY) {
1835
- var temp = parent.activeObj.activePoint.endY;
1836
- parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY;
1837
- parent.activeObj.activePoint.startY = temp;
1809
+ if (actPoint.endY < actPoint.startY) {
1810
+ var temp = actPoint.endY;
1811
+ actPoint.endY = actPoint.startY;
1812
+ actPoint.startY = temp;
1838
1813
  this.dragElement = parent.upperCanvas.style.cursor = parent.cursor = 'nw-resize';
1839
1814
  }
1840
- this.preventDraggingInvertly();
1815
+ this.revertResizing(tempActiveObj);
1841
1816
  }
1842
1817
  else {
1843
- if (parent.activeObj.activePoint.startX < x && parent.activeObj.activePoint.endY > y) {
1844
- width = x - parent.activeObj.activePoint.startX;
1845
- height = parent.activeObj.activePoint.endY - y;
1818
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
1819
+ if (actPoint.startX < x && actPoint.endY > y) {
1820
+ width = x - actPoint.startX;
1821
+ height = actPoint.endY - y;
1846
1822
  scale = Math.min(width, height);
1847
1823
  var newScale = this.getScaleRatio(scale);
1848
- parent.activeObj.activePoint.startX += newScale.x;
1849
- parent.activeObj.activePoint.endY -= newScale.y;
1850
- var endX = parent.img.destLeft > 0 ? parent.img.destLeft : 0;
1851
- var endY = parent.img.destTop + parent.img.destHeight < parent.lowerCanvas.height ? parent.img.destTop +
1852
- parent.img.destHeight : parent.lowerCanvas.height;
1853
- if (parent.activeObj.activePoint.startX < endX || parent.activeObj.activePoint.endY > endY) {
1854
- parent.activeObj.activePoint.startX -= newScale.x;
1855
- parent.activeObj.activePoint.endY += newScale.y;
1824
+ actPoint.startX += newScale.x;
1825
+ actPoint.endY -= newScale.y;
1826
+ var endX = destLeft > 0 ? destLeft : 0;
1827
+ var endY = destTop + destHeight < parent.lowerCanvas.height ? destTop +
1828
+ destHeight : parent.lowerCanvas.height;
1829
+ if (actPoint.startX < endX || actPoint.endY > endY) {
1830
+ actPoint.startX -= newScale.x;
1831
+ actPoint.endY += newScale.y;
1856
1832
  }
1857
1833
  }
1858
1834
  else {
1859
- width = parent.activeObj.activePoint.startX - x;
1860
- height = y - parent.activeObj.activePoint.endY;
1835
+ width = actPoint.startX - x;
1836
+ height = y - actPoint.endY;
1861
1837
  scale = Math.max(width, height);
1862
1838
  var newScale = this.getScaleRatio(scale);
1863
- parent.activeObj.activePoint.startX -= newScale.x;
1864
- parent.activeObj.activePoint.endY += newScale.y;
1865
- var endX = parent.img.destLeft > 0 ? parent.img.destLeft : 0;
1866
- var endY = parent.img.destTop + parent.img.destHeight < parent.lowerCanvas.height ? parent.img.destTop +
1867
- parent.img.destHeight : parent.lowerCanvas.height;
1868
- if (parent.activeObj.activePoint.startX < endX || parent.activeObj.activePoint.endY > endY) {
1869
- parent.activeObj.activePoint.startX += newScale.x;
1870
- parent.activeObj.activePoint.endY -= newScale.y;
1839
+ actPoint.startX -= newScale.x;
1840
+ actPoint.endY += newScale.y;
1841
+ var endX = destLeft > 0 ? destLeft : 0;
1842
+ var endY = destTop + destHeight < parent.lowerCanvas.height ? destTop +
1843
+ destHeight : parent.lowerCanvas.height;
1844
+ if (actPoint.startX < endX || actPoint.endY > endY) {
1845
+ actPoint.startX += newScale.x;
1846
+ actPoint.endY -= newScale.y;
1871
1847
  }
1872
1848
  }
1849
+ actPoint.width = actPoint.endX - actPoint.startX;
1850
+ actPoint.height = actPoint.endY - actPoint.startY;
1851
+ this.revertResizing(tempActiveObj);
1873
1852
  }
1874
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
1875
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
1853
+ actPoint.width = actPoint.endX - actPoint.startX;
1854
+ actPoint.height = actPoint.endY - actPoint.startY;
1876
1855
  this.preventInverseResize(tempActiveObj);
1877
1856
  }
1878
1857
  };
1879
1858
  Selection.prototype.updateSPoints = function (x, y) {
1880
1859
  var parent = this.parent;
1860
+ var actPoint = parent.activeObj.activePoint;
1881
1861
  var width;
1882
1862
  var height;
1883
1863
  var scale;
1864
+ var tempActiveObj = extend({}, parent.activeObj, null, true);
1884
1865
  if (parent.activeObj.shape !== 'text') {
1885
1866
  var splitWords = void 0;
1886
1867
  if (parent.activeObj.shape) {
@@ -1897,88 +1878,63 @@ var Selection = /** @class */ (function () {
1897
1878
  }
1898
1879
  width = (this.dragPoint.endX - this.previousPoint.x);
1899
1880
  height = (this.dragPoint.endY - this.previousPoint.y);
1900
- this.adjustRotationPoints(parent.activeObj.activePoint, width, height, parent.activeObj.rotatedAngle);
1881
+ this.adjustRotationPoints(actPoint, width, height, parent.activeObj.rotatedAngle);
1901
1882
  }
1902
1883
  else {
1903
- parent.activeObj.activePoint.endY = y;
1904
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
1884
+ actPoint.endY = y;
1885
+ actPoint.height = actPoint.endY - actPoint.startY;
1905
1886
  }
1906
- if (parent.activeObj.activePoint.endY < parent.activeObj.activePoint.startY) {
1907
- var temp = parent.activeObj.activePoint.endY;
1908
- parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY;
1909
- parent.activeObj.activePoint.startY = temp;
1887
+ if (actPoint.endY < actPoint.startY) {
1888
+ var temp = actPoint.endY;
1889
+ actPoint.endY = actPoint.startY;
1890
+ actPoint.startY = temp;
1910
1891
  this.dragElement = this.resizedElement = 'n-resize';
1911
1892
  }
1912
- this.preventDraggingInvertly();
1893
+ this.revertResizing(tempActiveObj);
1913
1894
  }
1914
1895
  else {
1915
- if (parent.activeObj.activePoint.endX > x && parent.activeObj.activePoint.endY > y) {
1916
- width = parent.activeObj.activePoint.endX - x;
1917
- height = parent.activeObj.activePoint.endY - y;
1896
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
1897
+ if (actPoint.endX > x && actPoint.endY > y) {
1898
+ width = actPoint.endX - x;
1899
+ height = actPoint.endY - y;
1918
1900
  scale = Math.min(width, height);
1919
1901
  var newScale = this.getScaleRatio(scale);
1920
- parent.activeObj.activePoint.endX -= newScale.x;
1921
- parent.activeObj.activePoint.endY -= newScale.y;
1922
- if (parent.activeObj.activePoint.endX > (parent.img.destLeft + parent.img.destWidth) ||
1923
- parent.activeObj.activePoint.endY > (parent.img.destTop + parent.img.destHeight)) {
1924
- parent.activeObj.activePoint.endX += newScale.x;
1925
- parent.activeObj.activePoint.endY += newScale.y;
1902
+ actPoint.endX -= newScale.x;
1903
+ actPoint.endY -= newScale.y;
1904
+ if (actPoint.endX > (destLeft + destWidth) ||
1905
+ actPoint.endY > (destTop + destHeight)) {
1906
+ actPoint.endX += newScale.x;
1907
+ actPoint.endY += newScale.y;
1926
1908
  }
1927
1909
  }
1928
1910
  else {
1929
- width = x - parent.activeObj.activePoint.endX;
1930
- height = y - parent.activeObj.activePoint.endY;
1911
+ width = x - actPoint.endX;
1912
+ height = y - actPoint.endY;
1931
1913
  scale = Math.max(width, height);
1932
1914
  var newScale = this.getScaleRatio(scale);
1933
- parent.activeObj.activePoint.endX += newScale.x;
1934
- parent.activeObj.activePoint.endY += newScale.x;
1935
- if (parent.activeObj.activePoint.endX > (parent.img.destLeft + parent.img.destWidth) ||
1936
- parent.activeObj.activePoint.endY > (parent.img.destTop + parent.img.destHeight)) {
1937
- parent.activeObj.activePoint.endX -= newScale.x;
1938
- parent.activeObj.activePoint.endY -= newScale.y;
1915
+ actPoint.endX += newScale.x;
1916
+ actPoint.endY += newScale.x;
1917
+ if (actPoint.endX > (destLeft + destWidth) ||
1918
+ actPoint.endY > (destTop + destHeight)) {
1919
+ actPoint.endX -= newScale.x;
1920
+ actPoint.endY -= newScale.y;
1939
1921
  }
1940
1922
  }
1941
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
1942
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
1923
+ actPoint.width = actPoint.endX - actPoint.startX;
1924
+ actPoint.height = actPoint.endY - actPoint.startY;
1925
+ this.revertResizing(tempActiveObj);
1943
1926
  }
1944
1927
  }
1945
1928
  };
1946
1929
  Selection.prototype.updateSEPoints = function (x, y, maxDimension) {
1947
1930
  var parent = this.parent;
1948
- var diff;
1931
+ var actPoint = parent.activeObj.activePoint;
1949
1932
  var width;
1950
1933
  var height;
1951
1934
  var scale;
1952
- var percentage;
1953
- var prevDiffX = this.diffPoint.x;
1954
- var prevDiffY = this.diffPoint.y;
1955
1935
  var tempActiveObj = extend({}, parent.activeObj, null, true);
1956
1936
  if (parent.activeObj.shape === 'text') {
1957
- if (this.oldPoint.x === undefined && this.oldPoint.y === undefined) {
1958
- this.diffPoint.x = x - parent.activeObj.activePoint.endX;
1959
- this.diffPoint.y = y - parent.activeObj.activePoint.endY;
1960
- }
1961
- else {
1962
- this.diffPoint.x = x - this.oldPoint.x;
1963
- this.diffPoint.y = y - this.oldPoint.y;
1964
- }
1965
- this.oldPoint.x = x;
1966
- this.oldPoint.y = y;
1967
- if (this.diffPoint.x >= prevDiffX && this.diffPoint.y >= prevDiffY) {
1968
- diff = Math.max(this.diffPoint.x, this.diffPoint.y);
1969
- }
1970
- else {
1971
- diff = Math.min(this.diffPoint.x, this.diffPoint.y);
1972
- }
1973
- percentage = (diff / 10);
1974
- parent.activeObj.activePoint.endX += (maxDimension.width / 50) * percentage;
1975
- parent.activeObj.activePoint.endY += (maxDimension.height / 50) * percentage;
1976
- if (this.preventTextDraggingInvertly()) {
1977
- parent.activeObj.activePoint.endX -= (maxDimension.width / 50) * percentage;
1978
- parent.activeObj.activePoint.endY -= (maxDimension.height / 50) * percentage;
1979
- }
1980
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
1981
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
1937
+ this.resizeImg(x, y, 'se-resize', tempActiveObj);
1982
1938
  parent.notify('shape', { prop: 'updateFontSize', onPropertyChange: false,
1983
1939
  value: { obj: parent.activeObj } });
1984
1940
  }
@@ -1993,63 +1949,66 @@ var Selection = /** @class */ (function () {
1993
1949
  this.resizeImg(x, y, 'se-resize', tempActiveObj);
1994
1950
  }
1995
1951
  else {
1996
- this.adjustSEPoints(parent.activeObj.activePoint, x, y, parent.activeObj.rotatedAngle);
1952
+ this.adjustSEPoints(actPoint, x, y, parent.activeObj.rotatedAngle);
1997
1953
  }
1998
- if (parent.activeObj.activePoint.endX < parent.activeObj.activePoint.startX) {
1999
- var temp = parent.activeObj.activePoint.endX;
2000
- parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX;
2001
- parent.activeObj.activePoint.startX = temp;
1954
+ if (actPoint.endX < actPoint.startX) {
1955
+ var temp = actPoint.endX;
1956
+ actPoint.endX = actPoint.startX;
1957
+ actPoint.startX = temp;
2002
1958
  this.dragElement = parent.upperCanvas.style.cursor = parent.cursor = 'sw-resize';
2003
1959
  }
2004
- if (parent.activeObj.activePoint.endY < parent.activeObj.activePoint.startY) {
2005
- var temp = parent.activeObj.activePoint.endY;
2006
- parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY;
2007
- parent.activeObj.activePoint.startY = temp;
1960
+ if (actPoint.endY < actPoint.startY) {
1961
+ var temp = actPoint.endY;
1962
+ actPoint.endY = actPoint.startY;
1963
+ actPoint.startY = temp;
2008
1964
  this.dragElement = parent.upperCanvas.style.cursor = parent.cursor = 'ne-resize';
2009
1965
  }
2010
- this.preventDraggingInvertly();
1966
+ this.revertResizing(tempActiveObj);
2011
1967
  }
2012
1968
  else {
2013
- if (parent.activeObj.activePoint.endX > x && parent.activeObj.activePoint.endY > y) {
2014
- width = parent.activeObj.activePoint.endX - x;
2015
- height = parent.activeObj.activePoint.endY - y;
1969
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
1970
+ if (actPoint.endX > x && actPoint.endY > y) {
1971
+ width = actPoint.endX - x;
1972
+ height = actPoint.endY - y;
2016
1973
  scale = Math.min(width, height);
2017
1974
  newScale = this.getScaleRatio(scale);
2018
- parent.activeObj.activePoint.endX -= newScale.x;
2019
- parent.activeObj.activePoint.endY -= newScale.y;
2020
- var endX = parent.img.destLeft + parent.img.destWidth < parent.lowerCanvas.width ?
2021
- parent.img.destLeft + parent.img.destWidth : parent.lowerCanvas.width;
2022
- var endY = parent.img.destTop + parent.img.destHeight < parent.lowerCanvas.height ?
2023
- parent.img.destTop + parent.img.destHeight : parent.lowerCanvas.height;
2024
- if (parent.activeObj.activePoint.endX > endX || parent.activeObj.activePoint.endY > endY) {
2025
- parent.activeObj.activePoint.endX += newScale.x;
2026
- parent.activeObj.activePoint.endY += newScale.y;
1975
+ actPoint.endX -= newScale.x;
1976
+ actPoint.endY -= newScale.y;
1977
+ var endX = destLeft + destWidth < parent.lowerCanvas.width ?
1978
+ destLeft + destWidth : parent.lowerCanvas.width;
1979
+ var endY = destTop + destHeight < parent.lowerCanvas.height ?
1980
+ destTop + destHeight : parent.lowerCanvas.height;
1981
+ if (actPoint.endX > endX || actPoint.endY > endY) {
1982
+ actPoint.endX += newScale.x;
1983
+ actPoint.endY += newScale.y;
2027
1984
  }
2028
1985
  }
2029
1986
  else {
2030
- width = x - parent.activeObj.activePoint.endX;
2031
- height = y - parent.activeObj.activePoint.endY;
1987
+ width = x - actPoint.endX;
1988
+ height = y - actPoint.endY;
2032
1989
  scale = Math.max(width, height);
2033
1990
  newScale = this.getScaleRatio(scale);
2034
- parent.activeObj.activePoint.endX += newScale.x;
2035
- parent.activeObj.activePoint.endY += newScale.y;
2036
- var endX = parent.img.destLeft + parent.img.destWidth < parent.lowerCanvas.width ? parent.img.destLeft +
2037
- parent.img.destWidth : parent.lowerCanvas.width;
2038
- var endY = parent.img.destTop + parent.img.destHeight < parent.lowerCanvas.height ? parent.img.destTop +
2039
- parent.img.destHeight : parent.lowerCanvas.height;
2040
- if (parent.activeObj.activePoint.endX > endX || parent.activeObj.activePoint.endY > endY) {
2041
- parent.activeObj.activePoint.endX -= newScale.x;
2042
- parent.activeObj.activePoint.endY -= newScale.y;
1991
+ actPoint.endX += newScale.x;
1992
+ actPoint.endY += newScale.y;
1993
+ var endX = destLeft + destWidth < parent.lowerCanvas.width ? destLeft +
1994
+ destWidth : parent.lowerCanvas.width;
1995
+ var endY = destTop + destHeight < parent.lowerCanvas.height ? destTop +
1996
+ destHeight : parent.lowerCanvas.height;
1997
+ if (actPoint.endX > endX || actPoint.endY > endY) {
1998
+ actPoint.endX -= newScale.x;
1999
+ actPoint.endY -= newScale.y;
2043
2000
  }
2044
2001
  }
2002
+ actPoint.width = actPoint.endX - actPoint.startX;
2003
+ actPoint.height = actPoint.endY - actPoint.startY;
2004
+ this.revertResizing(tempActiveObj);
2045
2005
  }
2046
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
2047
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
2048
2006
  this.preventInverseResize(tempActiveObj);
2049
2007
  }
2050
2008
  };
2051
2009
  Selection.prototype.resizeImg = function (x, y, elem, tempActiveObj) {
2052
2010
  var parent = this.parent;
2011
+ var actPoint = parent.activeObj.activePoint;
2053
2012
  var width;
2054
2013
  var height;
2055
2014
  var scale;
@@ -2063,14 +2022,14 @@ var Selection = /** @class */ (function () {
2063
2022
  height = (this.previousPoint.y - y);
2064
2023
  scale = (width + height) / 2;
2065
2024
  newScale = this.getScaleRatio(scale);
2066
- this.adjustRotationPoints(parent.activeObj.activePoint, -Math.abs(newScale.x), -Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2025
+ this.adjustRotationPoints(actPoint, -Math.abs(newScale.x), -Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2067
2026
  }
2068
2027
  else if (this.previousPoint.x !== 0 && this.previousPoint.y !== 0) {
2069
2028
  width = (x - this.previousPoint.x);
2070
2029
  height = (y - this.previousPoint.y);
2071
2030
  scale = (width + height) / 2;
2072
2031
  newScale = this.getScaleRatio(scale);
2073
- this.adjustRotationPoints(parent.activeObj.activePoint, Math.abs(newScale.x), Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2032
+ this.adjustRotationPoints(actPoint, Math.abs(newScale.x), Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2074
2033
  }
2075
2034
  break;
2076
2035
  case 'sw-resize':
@@ -2079,14 +2038,14 @@ var Selection = /** @class */ (function () {
2079
2038
  height = (this.previousPoint.y - y);
2080
2039
  scale = (width + height) / 2;
2081
2040
  newScale = this.getScaleRatio(scale);
2082
- this.adjustRotationPoints(parent.activeObj.activePoint, -Math.abs(newScale.x), -Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2041
+ this.adjustRotationPoints(actPoint, -Math.abs(newScale.x), -Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2083
2042
  }
2084
2043
  else if (this.previousPoint.x !== 0 && this.previousPoint.y !== 0) {
2085
2044
  width = (this.previousPoint.x - x);
2086
2045
  height = (y - this.previousPoint.y);
2087
2046
  scale = (width + height) / 2;
2088
2047
  newScale = this.getScaleRatio(scale);
2089
- this.adjustRotationPoints(parent.activeObj.activePoint, Math.abs(newScale.x), Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2048
+ this.adjustRotationPoints(actPoint, Math.abs(newScale.x), Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2090
2049
  }
2091
2050
  break;
2092
2051
  case 'w-resize':
@@ -2096,14 +2055,14 @@ var Selection = /** @class */ (function () {
2096
2055
  height = (y - this.previousPoint.y);
2097
2056
  scale = (width + height) / 2;
2098
2057
  newScale = this.getScaleRatio(scale);
2099
- this.adjustRotationPoints(parent.activeObj.activePoint, -Math.abs(newScale.x), -Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2058
+ this.adjustRotationPoints(actPoint, -Math.abs(newScale.x), -Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2100
2059
  }
2101
2060
  else if (this.previousPoint.x !== 0 && this.previousPoint.y !== 0) {
2102
2061
  width = (this.previousPoint.x - x);
2103
2062
  height = (this.previousPoint.y - y);
2104
2063
  scale = (width + height) / 2;
2105
2064
  newScale = this.getScaleRatio(scale);
2106
- this.adjustRotationPoints(parent.activeObj.activePoint, Math.abs(newScale.x), Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2065
+ this.adjustRotationPoints(actPoint, Math.abs(newScale.x), Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2107
2066
  }
2108
2067
  break;
2109
2068
  case 'n-resize':
@@ -2113,14 +2072,14 @@ var Selection = /** @class */ (function () {
2113
2072
  height = (y - this.previousPoint.y);
2114
2073
  scale = (width + height) / 2;
2115
2074
  newScale = this.getScaleRatio(scale);
2116
- this.adjustRotationPoints(parent.activeObj.activePoint, -Math.abs(newScale.x), -Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2075
+ this.adjustRotationPoints(actPoint, -Math.abs(newScale.x), -Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2117
2076
  }
2118
2077
  else if (this.previousPoint.x !== 0 && this.previousPoint.y !== 0) {
2119
2078
  width = (x - this.previousPoint.x);
2120
2079
  height = (this.previousPoint.y - y);
2121
2080
  scale = (width + height) / 2;
2122
2081
  newScale = this.getScaleRatio(scale);
2123
- this.adjustRotationPoints(parent.activeObj.activePoint, Math.abs(newScale.x), Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2082
+ this.adjustRotationPoints(actPoint, Math.abs(newScale.x), Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2124
2083
  }
2125
2084
  break;
2126
2085
  case 'e-resize':
@@ -2129,20 +2088,21 @@ var Selection = /** @class */ (function () {
2129
2088
  height = (this.previousPoint.y - y);
2130
2089
  scale = (width + height) / 2;
2131
2090
  newScale = this.getScaleRatio(scale);
2132
- this.adjustRotationPoints(parent.activeObj.activePoint, -Math.abs(newScale.x), -Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2091
+ this.adjustRotationPoints(actPoint, -Math.abs(newScale.x), -Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2133
2092
  }
2134
2093
  else if (this.previousPoint.x !== 0 && this.previousPoint.y !== 0) {
2135
2094
  width = (x - this.previousPoint.x);
2136
2095
  height = (y - this.previousPoint.y);
2137
2096
  scale = (width + height) / 2;
2138
2097
  newScale = this.getScaleRatio(scale);
2139
- this.adjustRotationPoints(parent.activeObj.activePoint, Math.abs(newScale.x), Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2098
+ this.adjustRotationPoints(actPoint, Math.abs(newScale.x), Math.abs(newScale.y), parent.activeObj.rotatedAngle, 'img-resize', elem);
2140
2099
  }
2141
2100
  break;
2142
2101
  }
2143
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
2144
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
2145
- if (parent.activeObj.activePoint.width < 10 || parent.activeObj.activePoint.height < 10) {
2102
+ actPoint.width = actPoint.endX - actPoint.startX;
2103
+ actPoint.height = actPoint.endY - actPoint.startY;
2104
+ if ((actPoint.width < 10 || actPoint.height < 10) ||
2105
+ (parent.activeObj.shape === 'text' && parent.activeObj.rotatedAngle === 0 && this.preventTextDraggingInvertly())) {
2146
2106
  parent.activeObj = extend({}, tempActiveObj, null, true);
2147
2107
  }
2148
2108
  }
@@ -2260,6 +2220,9 @@ var Selection = /** @class */ (function () {
2260
2220
  case 'x-y':
2261
2221
  value += (x + (y / 2));
2262
2222
  break;
2223
+ case 'y-x':
2224
+ value += (y + (x / 2));
2225
+ break;
2263
2226
  case 'img-resize-x':
2264
2227
  value += x;
2265
2228
  break;
@@ -2308,6 +2271,22 @@ var Selection = /** @class */ (function () {
2308
2271
  rectangle.startY = rectangle.endY - rectangle.height;
2309
2272
  }
2310
2273
  }
2274
+ else if (type && type === 'text') {
2275
+ if (elem === 'widthHeight') {
2276
+ rectangle.width = this.setResizedValue('x-y', rectangle.width, x, y);
2277
+ rectangle.endX = rectangle.width + rectangle.startX;
2278
+ rectangle.height = this.setResizedValue('y-x', rectangle.height, x, y);
2279
+ rectangle.endY = rectangle.height + rectangle.startY;
2280
+ }
2281
+ else if (elem === 'width') {
2282
+ rectangle.width = this.setResizedValue('x-y', rectangle.width, x, y);
2283
+ rectangle.endX = rectangle.width + rectangle.startX;
2284
+ }
2285
+ else if (elem === 'height') {
2286
+ rectangle.height = this.setResizedValue('y-abs-x', rectangle.height, x, y);
2287
+ rectangle.endY = rectangle.height + rectangle.startY;
2288
+ }
2289
+ }
2311
2290
  };
2312
2291
  Selection.prototype.getResizedElement = function (degree, element) {
2313
2292
  var resizeMappings = [];
@@ -2404,7 +2383,7 @@ var Selection = /** @class */ (function () {
2404
2383
  else if (actObj.rotatedAngle) {
2405
2384
  this.setCursorForRotatedObject(actObj, x, y, parent.upperCanvas);
2406
2385
  if (parent.cursor === 'grabbing') {
2407
- parent.upperCanvas.style.cursor = this.parent.cursor = 'grabbing';
2386
+ parent.upperCanvas.style.cursor = parent.cursor = 'grabbing';
2408
2387
  this.dragElement = parent.cursor;
2409
2388
  }
2410
2389
  else if (parent.cursor === 'move') {
@@ -2419,83 +2398,84 @@ var Selection = /** @class */ (function () {
2419
2398
  }
2420
2399
  else {
2421
2400
  var rotationCirclePoint = this.getTransRotationPoint(actObj);
2422
- if (x >= (actObj.topLeftCircle.startX - (actObj.topLeftCircle.radius * 2)) &&
2423
- x <= (actObj.topLeftCircle.startX + (actObj.topLeftCircle.radius * 2)) &&
2424
- y >= (actObj.topLeftCircle.startY - (actObj.topLeftCircle.radius * 2)) &&
2425
- y <= (actObj.topLeftCircle.startY + (actObj.topLeftCircle.radius * 2)) && this.dragElement !== 'nw-resize') {
2401
+ var radius = actObj.topLeftCircle.radius;
2402
+ if (x >= (actObj.topLeftCircle.startX - (radius * 2)) &&
2403
+ x <= (actObj.topLeftCircle.startX + (radius * 2)) &&
2404
+ y >= (actObj.topLeftCircle.startY - (radius * 2)) &&
2405
+ y <= (actObj.topLeftCircle.startY + (radius * 2)) && this.dragElement !== 'nw-resize') {
2426
2406
  actObj.topLeftCircle.startX = actObj.topLeftCircle.startY = 0;
2427
2407
  parent.upperCanvas.style.cursor = parent.cursor = 'nw-resize';
2428
2408
  isResize = true;
2429
2409
  this.dragElement = parent.upperCanvas.style.cursor;
2430
2410
  }
2431
- else if (x >= (actObj.topLeftCircle.startX - (actObj.topLeftCircle.radius * 2)) &&
2432
- x <= (actObj.topRightCircle.startX - (actObj.topLeftCircle.radius * 2)) &&
2433
- y >= (actObj.topCenterCircle.startY - (actObj.topLeftCircle.radius * 2)) &&
2434
- y <= (actObj.topCenterCircle.startY + (actObj.topLeftCircle.radius * 2)) && this.dragElement !== 'n-resize') {
2411
+ else if (x >= (actObj.topLeftCircle.startX - (radius * 2)) &&
2412
+ x <= (actObj.topRightCircle.startX - (radius * 2)) &&
2413
+ y >= (actObj.topCenterCircle.startY - (radius * 2)) &&
2414
+ y <= (actObj.topCenterCircle.startY + (radius * 2)) && this.dragElement !== 'n-resize') {
2435
2415
  actObj.topCenterCircle.startX = actObj.topCenterCircle.startY = 0;
2436
2416
  parent.upperCanvas.style.cursor = parent.cursor = 'n-resize';
2437
2417
  isResize = true;
2438
2418
  this.dragElement = parent.upperCanvas.style.cursor;
2439
2419
  }
2440
- else if (x >= (actObj.topRightCircle.startX - (actObj.topLeftCircle.radius * 2)) &&
2441
- x <= (actObj.topRightCircle.startX + (actObj.topLeftCircle.radius * 2)) &&
2442
- y >= (actObj.topRightCircle.startY - (actObj.topLeftCircle.radius * 2)) &&
2443
- y <= (actObj.topRightCircle.startY + (actObj.topLeftCircle.radius * 2)) && this.dragElement !== 'ne-resize') {
2420
+ else if (x >= (actObj.topRightCircle.startX - (radius * 2)) &&
2421
+ x <= (actObj.topRightCircle.startX + (radius * 2)) &&
2422
+ y >= (actObj.topRightCircle.startY - (radius * 2)) &&
2423
+ y <= (actObj.topRightCircle.startY + (radius * 2)) && this.dragElement !== 'ne-resize') {
2444
2424
  actObj.topRightCircle.startX = actObj.topRightCircle.startY = 0;
2445
2425
  parent.upperCanvas.style.cursor = parent.cursor = 'ne-resize';
2446
2426
  isResize = true;
2447
2427
  this.dragElement = parent.upperCanvas.style.cursor;
2448
2428
  }
2449
- else if (x >= (actObj.centerLeftCircle.startX - (actObj.topLeftCircle.radius * 2)) &&
2450
- x <= (actObj.centerLeftCircle.startX + (actObj.topLeftCircle.radius * 2)) &&
2451
- y >= (actObj.topLeftCircle.startY - (actObj.topLeftCircle.radius * 2)) &&
2452
- y <= (actObj.bottomLeftCircle.startY - (actObj.topLeftCircle.radius * 2)) && this.dragElement !== 'w-resize') {
2429
+ else if (x >= (actObj.centerLeftCircle.startX - (radius * 2)) &&
2430
+ x <= (actObj.centerLeftCircle.startX + (radius * 2)) &&
2431
+ y >= (actObj.topLeftCircle.startY - (radius * 2)) &&
2432
+ y <= (actObj.bottomLeftCircle.startY - (radius * 2)) && this.dragElement !== 'w-resize') {
2453
2433
  actObj.centerLeftCircle.startX = actObj.centerLeftCircle.startY = 0;
2454
2434
  parent.upperCanvas.style.cursor = parent.cursor = 'w-resize';
2455
2435
  isResize = true;
2456
2436
  this.dragElement = parent.upperCanvas.style.cursor;
2457
2437
  }
2458
- else if (x >= (actObj.centerRightCircle.startX - (actObj.topLeftCircle.radius * 2)) &&
2459
- x <= (actObj.centerRightCircle.startX + (actObj.topLeftCircle.radius * 2)) &&
2460
- y >= (actObj.topRightCircle.startY - (actObj.topLeftCircle.radius * 2)) &&
2461
- y <= (actObj.bottomRightCircle.startY - (actObj.topLeftCircle.radius * 2)) && this.dragElement !== 'e-resize') {
2438
+ else if (x >= (actObj.centerRightCircle.startX - (radius * 2)) &&
2439
+ x <= (actObj.centerRightCircle.startX + (radius * 2)) &&
2440
+ y >= (actObj.topRightCircle.startY - (radius * 2)) &&
2441
+ y <= (actObj.bottomRightCircle.startY - (radius * 2)) && this.dragElement !== 'e-resize') {
2462
2442
  actObj.centerRightCircle.startX = actObj.centerRightCircle.startY = 0;
2463
2443
  parent.upperCanvas.style.cursor = parent.cursor = 'e-resize';
2464
2444
  isResize = true;
2465
2445
  this.dragElement = parent.upperCanvas.style.cursor;
2466
2446
  }
2467
- else if (x >= (actObj.bottomLeftCircle.startX - (actObj.topLeftCircle.radius * 2)) &&
2468
- x <= (actObj.bottomLeftCircle.startX + (actObj.topLeftCircle.radius * 2)) &&
2469
- y >= (actObj.bottomLeftCircle.startY - (actObj.topLeftCircle.radius * 2)) &&
2470
- y <= (actObj.bottomLeftCircle.startY + (actObj.topLeftCircle.radius * 2)) && this.dragElement !== 'sw-resize') {
2447
+ else if (x >= (actObj.bottomLeftCircle.startX - (radius * 2)) &&
2448
+ x <= (actObj.bottomLeftCircle.startX + (radius * 2)) &&
2449
+ y >= (actObj.bottomLeftCircle.startY - (radius * 2)) &&
2450
+ y <= (actObj.bottomLeftCircle.startY + (radius * 2)) && this.dragElement !== 'sw-resize') {
2471
2451
  actObj.bottomLeftCircle.startX = actObj.bottomLeftCircle.startY = 0;
2472
2452
  parent.upperCanvas.style.cursor = parent.cursor = 'sw-resize';
2473
2453
  isResize = true;
2474
2454
  this.dragElement = parent.upperCanvas.style.cursor;
2475
2455
  }
2476
- else if (x >= (actObj.bottomLeftCircle.startX - (actObj.topLeftCircle.radius * 2)) &&
2477
- x <= (actObj.bottomRightCircle.startX - (actObj.topLeftCircle.radius * 2)) &&
2478
- y >= (actObj.bottomCenterCircle.startY - (actObj.topLeftCircle.radius * 2)) &&
2479
- y <= (actObj.bottomCenterCircle.startY + (actObj.topLeftCircle.radius * 2)) && this.dragElement !== 's-resize') {
2456
+ else if (x >= (actObj.bottomLeftCircle.startX - (radius * 2)) &&
2457
+ x <= (actObj.bottomRightCircle.startX - (radius * 2)) &&
2458
+ y >= (actObj.bottomCenterCircle.startY - (radius * 2)) &&
2459
+ y <= (actObj.bottomCenterCircle.startY + (radius * 2)) && this.dragElement !== 's-resize') {
2480
2460
  actObj.bottomCenterCircle.startX = actObj.bottomCenterCircle.startY = 0;
2481
2461
  parent.upperCanvas.style.cursor = parent.cursor = 's-resize';
2482
2462
  isResize = true;
2483
2463
  this.dragElement = parent.upperCanvas.style.cursor;
2484
2464
  }
2485
- else if (x >= (actObj.bottomRightCircle.startX - (actObj.topLeftCircle.radius * 2)) &&
2486
- x <= (actObj.bottomRightCircle.startX + (actObj.topLeftCircle.radius * 2)) &&
2487
- y >= (actObj.bottomRightCircle.startY - (actObj.topLeftCircle.radius * 2)) &&
2488
- y <= (actObj.bottomRightCircle.startY + (actObj.topLeftCircle.radius * 2)) && this.dragElement !== 'se-resize') {
2465
+ else if (x >= (actObj.bottomRightCircle.startX - (radius * 2)) &&
2466
+ x <= (actObj.bottomRightCircle.startX + (radius * 2)) &&
2467
+ y >= (actObj.bottomRightCircle.startY - (radius * 2)) &&
2468
+ y <= (actObj.bottomRightCircle.startY + (radius * 2)) && this.dragElement !== 'se-resize') {
2489
2469
  actObj.bottomRightCircle.startX = actObj.bottomRightCircle.startY = 0;
2490
2470
  parent.upperCanvas.style.cursor = parent.cursor = 'se-resize';
2491
2471
  isResize = true;
2492
2472
  this.dragElement = parent.upperCanvas.style.cursor;
2493
2473
  }
2494
2474
  else if (rotationCirclePoint &&
2495
- x >= rotationCirclePoint.x - (actObj.topLeftCircle.radius * 2) &&
2496
- x <= rotationCirclePoint.x + (actObj.topLeftCircle.radius * 2) &&
2497
- y >= rotationCirclePoint.y - (actObj.topLeftCircle.radius * 2) &&
2498
- y <= rotationCirclePoint.y + (actObj.topLeftCircle.radius * 2) && this.dragElement !== 'grabbing') {
2475
+ x >= rotationCirclePoint.x - (radius * 2) &&
2476
+ x <= rotationCirclePoint.x + (radius * 2) &&
2477
+ y >= rotationCirclePoint.y - (radius * 2) &&
2478
+ y <= rotationCirclePoint.y + (radius * 2) && this.dragElement !== 'grabbing') {
2499
2479
  parent.upperCanvas.style.cursor = parent.cursor = 'grabbing';
2500
2480
  this.dragElement = parent.upperCanvas.style.cursor;
2501
2481
  }
@@ -2550,10 +2530,11 @@ var Selection = /** @class */ (function () {
2550
2530
  var isResize = false;
2551
2531
  var parent = this.parent;
2552
2532
  var point;
2533
+ var radius = actObj.topLeftCircle.radius;
2553
2534
  for (var i = 0; i < 5; i++) {
2554
2535
  point = actObj.pointColl[i];
2555
- if (x >= (point.x - (actObj.topLeftCircle.radius * 2)) && x <= (point.x + (actObj.topLeftCircle.radius * 2)) &&
2556
- y >= (point.y - (actObj.topLeftCircle.radius * 2)) && y <= (point.y + (actObj.topLeftCircle.radius * 2))) {
2536
+ if (x >= (point.x - (radius * 2)) && x <= (point.x + (radius * 2)) &&
2537
+ y >= (point.y - (radius * 2)) && y <= (point.y + (radius * 2))) {
2557
2538
  actObj.centerLeftCircle.startX = actObj.centerLeftCircle.startY = 0;
2558
2539
  this.dragElement = 'w-resize';
2559
2540
  isResize = true;
@@ -2563,8 +2544,8 @@ var Selection = /** @class */ (function () {
2563
2544
  if (!isResize) {
2564
2545
  for (var i = 1; i < 6; i++) {
2565
2546
  point = actObj.pointColl[actObj.pointColl.length - i];
2566
- if (x >= (point.x - (actObj.topLeftCircle.radius * 2)) && x <= (point.x + (actObj.topLeftCircle.radius * 2)) &&
2567
- y >= (point.y - (actObj.topLeftCircle.radius * 2)) && y <= (point.y + (actObj.topLeftCircle.radius * 2))) {
2547
+ if (x >= (point.x - (radius * 2)) && x <= (point.x + (radius * 2)) &&
2548
+ y >= (point.y - (radius * 2)) && y <= (point.y + (radius * 2))) {
2568
2549
  actObj.centerRightCircle.startX = actObj.centerRightCircle.startY = 0;
2569
2550
  this.dragElement = 'e-resize';
2570
2551
  isResize = true;
@@ -2575,8 +2556,8 @@ var Selection = /** @class */ (function () {
2575
2556
  if (!isResize) {
2576
2557
  for (var i = 0; i < actObj.pointColl.length; i++) {
2577
2558
  point = actObj.pointColl[i];
2578
- if (x >= (point.x - (actObj.topLeftCircle.radius * 2)) && x <= (point.x + (actObj.topLeftCircle.radius * 2)) &&
2579
- y >= (point.y - (actObj.topLeftCircle.radius * 2)) && y <= (point.y + (actObj.topLeftCircle.radius * 2))) {
2559
+ if (x >= (point.x - (radius * 2)) && x <= (point.x + (radius * 2)) &&
2560
+ y >= (point.y - (radius * 2)) && y <= (point.y + (radius * 2))) {
2580
2561
  parent.upperCanvas.style.cursor = parent.cursor = 'move';
2581
2562
  this.dragPoint.startX = this.previousPoint.x = this.dragPoint.endX = x;
2582
2563
  this.dragPoint.startY = this.previousPoint.y = this.dragPoint.endY = y;
@@ -2591,13 +2572,14 @@ var Selection = /** @class */ (function () {
2591
2572
  };
2592
2573
  Selection.prototype.updateCursorStylesForPath = function (x, y, actObj) {
2593
2574
  var isResize = false;
2594
- this.pathAdjustedIndex = this.setCursorForLineArrow(actObj, x, y, this.parent.upperCanvas);
2595
- if (this.parent.cursor === 'move') {
2575
+ var parent = this.parent;
2576
+ this.pathAdjustedIndex = this.setCursorForLineArrow(actObj, x, y, parent.upperCanvas);
2577
+ if (parent.cursor === 'move') {
2596
2578
  isResize = true;
2597
2579
  this.dragElement = 'pathDrag';
2598
2580
  }
2599
2581
  if (!isResize) {
2600
- this.parent.upperCanvas.style.cursor = this.parent.cursor = 'move';
2582
+ parent.upperCanvas.style.cursor = parent.cursor = 'move';
2601
2583
  this.dragPoint.startX = this.previousPoint.x = this.dragPoint.endX = x;
2602
2584
  this.dragPoint.startY = this.previousPoint.y = this.dragPoint.endY = y;
2603
2585
  }
@@ -2605,6 +2587,7 @@ var Selection = /** @class */ (function () {
2605
2587
  };
2606
2588
  Selection.prototype.setTextSelection = function (width, height) {
2607
2589
  var parent = this.parent;
2590
+ var actPoint = parent.activeObj.activePoint;
2608
2591
  var degree = parent.transform.degree;
2609
2592
  if (parent.activeObj.shapeDegree === 0) {
2610
2593
  degree = parent.transform.degree;
@@ -2621,92 +2604,72 @@ var Selection = /** @class */ (function () {
2621
2604
  case 0:
2622
2605
  switch (flip) {
2623
2606
  case 'horizontal':
2624
- parent.activeObj.activePoint = { startX: parent.activeObj.activePoint.endX - width,
2625
- startY: parent.activeObj.activePoint.startY,
2626
- endX: (parent.activeObj.activePoint.endX),
2627
- endY: parent.activeObj.activePoint.startY + (height ? height : 0) };
2607
+ actPoint = { startX: actPoint.endX - width, startY: actPoint.startY, endX: (actPoint.endX),
2608
+ endY: actPoint.startY + (height ? height : 0) };
2628
2609
  break;
2629
2610
  case 'vertical':
2630
- parent.activeObj.activePoint.startY = parent.activeObj.activePoint.endY - height;
2631
- parent.activeObj.activePoint = { startX: parent.activeObj.activePoint.startX,
2632
- startY: parent.activeObj.activePoint.startY,
2633
- endX: (parent.activeObj.activePoint.startX + (width ? width : 0)),
2634
- endY: parent.activeObj.activePoint.endY };
2611
+ actPoint.startY = actPoint.endY - height;
2612
+ actPoint = { startX: actPoint.startX, startY: actPoint.startY, endX: (actPoint.startX + (width ? width : 0)),
2613
+ endY: actPoint.endY };
2635
2614
  break;
2636
2615
  default:
2637
- parent.activeObj.activePoint = { startX: parent.activeObj.activePoint.startX,
2638
- startY: parent.activeObj.activePoint.startY,
2639
- endX: (parent.activeObj.activePoint.startX + (width ? width : 0)),
2640
- endY: parent.activeObj.activePoint.startY + (height ? height : 0) };
2616
+ actPoint = { startX: actPoint.startX,
2617
+ startY: actPoint.startY, endX: (actPoint.startX + (width ? width : 0)), endY: actPoint.startY +
2618
+ (height ? height : 0) };
2641
2619
  break;
2642
2620
  }
2643
2621
  break;
2644
2622
  case 90:
2645
2623
  switch (flip) {
2646
2624
  case 'horizontal':
2647
- parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX + height;
2648
- parent.activeObj.activePoint = { startX: parent.activeObj.activePoint.startX,
2649
- startY: parent.activeObj.activePoint.startY, endX: (parent.activeObj.activePoint.endX),
2650
- endY: parent.activeObj.activePoint.startY + (width ? width : 0) };
2625
+ actPoint.endX = actPoint.startX + height;
2626
+ actPoint = { startX: actPoint.startX, startY: actPoint.startY, endX: (actPoint.endX),
2627
+ endY: actPoint.startY + (width ? width : 0) };
2651
2628
  break;
2652
2629
  case 'vertical':
2653
- parent.activeObj.activePoint.startX = parent.activeObj.activePoint.endX - height;
2654
- parent.activeObj.activePoint = { startX: parent.activeObj.activePoint.startX,
2655
- startY: parent.activeObj.activePoint.endY - width,
2656
- endX: (parent.activeObj.activePoint.endX),
2657
- endY: parent.activeObj.activePoint.endY };
2630
+ actPoint.startX = actPoint.endX - height;
2631
+ actPoint = { startX: actPoint.startX, startY: actPoint.endY - width, endX: (actPoint.endX), endY: actPoint.endY };
2658
2632
  break;
2659
2633
  default:
2660
- parent.activeObj.activePoint.startX = parent.activeObj.activePoint.endX - height;
2661
- parent.activeObj.activePoint = { startX: parent.activeObj.activePoint.startX,
2662
- startY: parent.activeObj.activePoint.startY, endX: (parent.activeObj.activePoint.endX),
2663
- endY: parent.activeObj.activePoint.startY + (width ? width : 0) };
2634
+ actPoint.startX = actPoint.endX - height;
2635
+ actPoint = { startX: actPoint.startX, startY: actPoint.startY, endX: (actPoint.endX),
2636
+ endY: actPoint.startY + (width ? width : 0) };
2664
2637
  break;
2665
2638
  }
2666
2639
  break;
2667
2640
  case 180:
2668
2641
  switch (flip) {
2669
2642
  case 'horizontal':
2670
- parent.activeObj.activePoint.startY = parent.activeObj.activePoint.endY - height;
2671
- parent.activeObj.activePoint = { startX: parent.activeObj.activePoint.startX,
2672
- startY: parent.activeObj.activePoint.startY,
2673
- endX: (parent.activeObj.activePoint.startX + width),
2674
- endY: parent.activeObj.activePoint.endY };
2643
+ actPoint.startY = actPoint.endY - height;
2644
+ actPoint = { startX: actPoint.startX, startY: actPoint.startY, endX: (actPoint.startX + width),
2645
+ endY: actPoint.endY };
2675
2646
  break;
2676
2647
  case 'vertical':
2677
- parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY + height;
2678
- parent.activeObj.activePoint = { endX: parent.activeObj.activePoint.endX, endY: parent.activeObj.activePoint.endY,
2679
- startX: (parent.activeObj.activePoint.endX - (width ? width : 0)),
2680
- startY: parent.activeObj.activePoint.startY };
2648
+ actPoint.endY = actPoint.startY + height;
2649
+ actPoint = { endX: actPoint.endX, endY: actPoint.endY, startX: (actPoint.endX - (width ? width : 0)),
2650
+ startY: actPoint.startY };
2681
2651
  break;
2682
2652
  default:
2683
- parent.activeObj.activePoint = { endX: parent.activeObj.activePoint.endX, endY: parent.activeObj.activePoint.endY,
2684
- startX: (parent.activeObj.activePoint.endX - (width ? width : 0)),
2685
- startY: parent.activeObj.activePoint.endY - (height ? height : 0) };
2653
+ actPoint = { endX: actPoint.endX, endY: actPoint.endY, startX: (actPoint.endX - (width ? width : 0)),
2654
+ startY: actPoint.endY - (height ? height : 0) };
2686
2655
  break;
2687
2656
  }
2688
2657
  break;
2689
2658
  case 270:
2690
2659
  switch (flip) {
2691
2660
  case 'horizontal':
2692
- parent.activeObj.activePoint.startX = parent.activeObj.activePoint.endX - height;
2693
- parent.activeObj.activePoint = { startX: parent.activeObj.activePoint.startX,
2694
- startY: parent.activeObj.activePoint.endY - (width ? width : 0),
2695
- endX: parent.activeObj.activePoint.endX,
2696
- endY: parent.activeObj.activePoint.endY };
2661
+ actPoint.startX = actPoint.endX - height;
2662
+ actPoint = { startX: actPoint.startX, startY: actPoint.endY - (width ? width : 0), endX: actPoint.endX,
2663
+ endY: actPoint.endY };
2697
2664
  break;
2698
2665
  case 'vertical':
2699
- parent.activeObj.activePoint = { startX: parent.activeObj.activePoint.startX,
2700
- startY: parent.activeObj.activePoint.startY,
2701
- endX: (parent.activeObj.activePoint.startX + height),
2702
- endY: parent.activeObj.activePoint.startY + (width ? width : 0) };
2666
+ actPoint = { startX: actPoint.startX, startY: actPoint.startY, endX: (actPoint.startX + height),
2667
+ endY: actPoint.startY + (width ? width : 0) };
2703
2668
  break;
2704
2669
  default:
2705
- parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX + height;
2706
- parent.activeObj.activePoint = { startX: parent.activeObj.activePoint.startX,
2707
- startY: parent.activeObj.activePoint.endY - (width ? width : 0),
2708
- endX: parent.activeObj.activePoint.endX,
2709
- endY: parent.activeObj.activePoint.endY };
2670
+ actPoint.endX = actPoint.startX + height;
2671
+ actPoint = { startX: actPoint.startX, startY: actPoint.endY - (width ? width : 0), endX: actPoint.endX,
2672
+ endY: actPoint.endY };
2710
2673
  break;
2711
2674
  }
2712
2675
  break;
@@ -2715,39 +2678,36 @@ var Selection = /** @class */ (function () {
2715
2678
  if (parent.activeObj.flipObjColl.length === 0) {
2716
2679
  switch (degree) {
2717
2680
  case 0:
2718
- parent.activeObj.activePoint = { startX: parent.activeObj.activePoint.startX, startY: parent.activeObj.activePoint.startY,
2719
- endX: (parent.activeObj.activePoint.startX + (width ? width : 0)),
2720
- endY: parent.activeObj.activePoint.startY + (height ? height : 0) };
2681
+ actPoint = { startX: actPoint.startX, startY: actPoint.startY, endX: (actPoint.startX + (width ? width : 0)),
2682
+ endY: actPoint.startY + (height ? height : 0) };
2721
2683
  break;
2722
2684
  case 90:
2723
- parent.activeObj.activePoint.startX = parent.activeObj.activePoint.endX - height;
2724
- parent.activeObj.activePoint = { startX: parent.activeObj.activePoint.startX, startY: parent.activeObj.activePoint.startY,
2725
- endX: (parent.activeObj.activePoint.endX),
2726
- endY: parent.activeObj.activePoint.startY + (width ? width : 0) };
2685
+ actPoint.startX = actPoint.endX - height;
2686
+ actPoint = { startX: actPoint.startX, startY: actPoint.startY, endX: (actPoint.endX),
2687
+ endY: actPoint.startY + (width ? width : 0) };
2727
2688
  break;
2728
2689
  case 180:
2729
- parent.activeObj.activePoint = { endX: parent.activeObj.activePoint.endX, endY: parent.activeObj.activePoint.endY,
2730
- startX: (parent.activeObj.activePoint.endX - (width ? width : 0)),
2731
- startY: parent.activeObj.activePoint.endY - (height ? height : 0) };
2690
+ actPoint = { endX: actPoint.endX, endY: actPoint.endY, startX: (actPoint.endX - (width ? width : 0)),
2691
+ startY: actPoint.endY - (height ? height : 0) };
2732
2692
  break;
2733
2693
  case 270:
2734
- parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX + height;
2735
- parent.activeObj.activePoint = { startX: parent.activeObj.activePoint.startX,
2736
- startY: parent.activeObj.activePoint.endY - (width ? width : 0),
2737
- endX: parent.activeObj.activePoint.endX,
2738
- endY: parent.activeObj.activePoint.endY };
2694
+ actPoint.endX = actPoint.startX + height;
2695
+ actPoint = { startX: actPoint.startX, startY: actPoint.endY - (width ? width : 0), endX: actPoint.endX,
2696
+ endY: actPoint.endY };
2739
2697
  break;
2740
2698
  }
2741
2699
  }
2742
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
2743
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
2700
+ actPoint.width = actPoint.endX - actPoint.startX;
2701
+ actPoint.height = actPoint.endY - actPoint.startY;
2702
+ parent.activeObj.activePoint = actPoint;
2744
2703
  if (parent.transform.degree === 360 || parent.transform.degree === -360) {
2745
2704
  parent.transform.degree = 0;
2746
2705
  }
2747
2706
  };
2748
2707
  Selection.prototype.setActivePoint = function (startX, startY) {
2749
2708
  var parent = this.parent;
2750
- if (isNullOrUndefined(parent.activeObj.activePoint)) {
2709
+ var activePoint = parent.activeObj.activePoint;
2710
+ if (isNullOrUndefined(activePoint)) {
2751
2711
  return;
2752
2712
  }
2753
2713
  if (parent.currObjType.isText) {
@@ -2757,24 +2717,24 @@ var Selection = /** @class */ (function () {
2757
2717
  parent.activeObj.textSettings.fontSize = (Math.abs(parent.baseImgCanvas.width - parent.baseImgCanvas.height)) * 0.1;
2758
2718
  }
2759
2719
  this.setTextSelection(textWidth, textHeight);
2760
- this.mouseDownPoint.x = parent.activeObj.activePoint.endX;
2761
- this.mouseDownPoint.y = parent.activeObj.activePoint.endY;
2720
+ this.mouseDownPoint.x = activePoint.endX;
2721
+ this.mouseDownPoint.y = activePoint.endY;
2762
2722
  if (parent.activeObj.horTopLine !== undefined) {
2763
- parent.activeObj.activePoint = extend({}, parent.activeObj.activePoint, {}, true);
2723
+ parent.activeObj.activePoint = extend({}, activePoint, {}, true);
2764
2724
  }
2765
2725
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
2766
2726
  }
2767
2727
  else if (startX && startY) {
2768
- parent.activeObj.activePoint.startX = this.mouseDownPoint.x = startX;
2769
- parent.activeObj.activePoint.startY = this.mouseDownPoint.y = startY;
2728
+ activePoint.startX = this.mouseDownPoint.x = startX;
2729
+ activePoint.startY = this.mouseDownPoint.y = startY;
2770
2730
  parent.currObjType.isDragging = true;
2771
2731
  }
2772
2732
  else {
2773
2733
  var selectInfo = parent.activeObj;
2774
- parent.activeObj.activePoint = { startX: selectInfo.horTopLine.startX, startY: selectInfo.horTopLine.startY,
2734
+ activePoint = { startX: selectInfo.horTopLine.startX, startY: selectInfo.horTopLine.startY,
2775
2735
  endX: selectInfo.horTopLine.endX, endY: selectInfo.horTopLine.endY };
2776
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
2777
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
2736
+ activePoint.width = activePoint.endX - activePoint.startX;
2737
+ activePoint.height = activePoint.endY - activePoint.startY;
2778
2738
  }
2779
2739
  };
2780
2740
  Selection.prototype.mouseDownEventHandler = function (e) {
@@ -2815,29 +2775,31 @@ var Selection = /** @class */ (function () {
2815
2775
  };
2816
2776
  Selection.prototype.getImagePoints = function (x, y) {
2817
2777
  var parent = this.parent;
2818
- if (x < parent.img.destLeft) {
2819
- x = parent.img.destLeft;
2778
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
2779
+ if (x < destLeft) {
2780
+ x = destLeft;
2820
2781
  }
2821
- else if (x > parent.img.destLeft + parent.img.destWidth) {
2822
- x = parent.img.destLeft + parent.img.destWidth;
2782
+ else if (x > destLeft + destWidth) {
2783
+ x = destLeft + destWidth;
2823
2784
  }
2824
- if (y < parent.img.destTop) {
2825
- y = parent.img.destTop;
2785
+ if (y < destTop) {
2786
+ y = destTop;
2826
2787
  }
2827
- else if (y > parent.img.destTop + parent.img.destHeight) {
2828
- y = parent.img.destTop + parent.img.destHeight;
2788
+ else if (y > destTop + destHeight) {
2789
+ y = destTop + destHeight;
2829
2790
  }
2830
2791
  return { x: x, y: y };
2831
2792
  };
2832
2793
  Selection.prototype.clickEvent = function (imageEditorClickEventArgs, e) {
2833
2794
  var parent = this.parent;
2795
+ var activePoint = parent.activeObj.activePoint;
2834
2796
  var x = imageEditorClickEventArgs.point.x;
2835
2797
  var y = imageEditorClickEventArgs.point.y;
2836
2798
  var cursor = parent.activeObj.shape && parent.activeObj.shape === 'text' ?
2837
2799
  parent.cursor : 'default';
2838
2800
  if (parent.isResize) {
2839
- // parent.okBtn();
2840
2801
  this.performEnterAction();
2802
+ parent.upperCanvas.style.cursor = 'default';
2841
2803
  return;
2842
2804
  }
2843
2805
  else if (JSON.stringify(parent.frameObj) !== JSON.stringify(parent.tempFrameObj)) {
@@ -2858,25 +2820,25 @@ var Selection = /** @class */ (function () {
2858
2820
  if (this.currentDrawingShape === 'path') {
2859
2821
  var point = this.getImagePoints(x, y);
2860
2822
  parent.activeObj.pointColl.push({ x: point.x, y: point.y });
2861
- if (parent.activeObj.activePoint.width !== 0 && parent.activeObj.activePoint.height !== 0) {
2862
- parent.activeObj.activePoint.width = 0;
2863
- parent.activeObj.activePoint.height = 0;
2864
- parent.activeObj.activePoint.startX = parent.activeObj.pointColl[parent.activeObj.pointColl.length - 1].x;
2865
- parent.activeObj.activePoint.startY = parent.activeObj.pointColl[parent.activeObj.pointColl.length - 1].y;
2823
+ if (activePoint.width !== 0 && activePoint.height !== 0) {
2824
+ activePoint.width = 0;
2825
+ activePoint.height = 0;
2826
+ activePoint.startX = parent.activeObj.pointColl[parent.activeObj.pointColl.length - 1].x;
2827
+ activePoint.startY = parent.activeObj.pointColl[parent.activeObj.pointColl.length - 1].y;
2866
2828
  }
2867
2829
  }
2868
- parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX;
2869
- parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY;
2830
+ activePoint.endX = activePoint.startX;
2831
+ activePoint.endY = activePoint.startY;
2870
2832
  parent.currObjType.isDragging = true;
2871
2833
  var previousShapeSettings = this.updatePrevShapeSettings();
2872
- var shapeResizingArgs = { action: 'draw-start', previousShapeSettings: previousShapeSettings };
2873
- var shapeMovingArgs = { action: 'move', previousShapeSettings: previousShapeSettings };
2834
+ var shapeResizingArgs = { cancel: false, action: 'draw-start', previousShapeSettings: previousShapeSettings };
2835
+ var shapeMovingArgs = { cancel: false, action: 'move', previousShapeSettings: previousShapeSettings };
2874
2836
  this.shapeResizingArgs = shapeResizingArgs;
2875
2837
  this.shapeMovingArgs = shapeMovingArgs;
2876
2838
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'mouse-down');
2877
2839
  return;
2878
2840
  }
2879
- parent.notify('draw', { prop: 'resetFrameZoom', onPropertyChange: false });
2841
+ parent.notify('draw', { prop: 'resetFrameZoom', onPropertyChange: false, value: { isOk: true } });
2880
2842
  if (this.isCropSelection && this.dragCanvas) {
2881
2843
  this.setCursor(x, y);
2882
2844
  if (parent.cursor !== 'move' && parent.cursor !== 'crosshair' &&
@@ -2898,6 +2860,7 @@ var Selection = /** @class */ (function () {
2898
2860
  var isFreehandDraw = this.isFreehandDrawTouch(e, this.isCropSelection);
2899
2861
  var isShapeClick = isShape ? isShape : this.isShapeClick(e, this.isCropSelection);
2900
2862
  var allowUndoRedoPush = this.applyCurrShape(isShapeClick);
2863
+ var isTextArea = parent.textArea.style.display !== 'none' ? true : false;
2901
2864
  if (this.isTouch && !isShape && activeObj.shape && !this.isCropSelection) {
2902
2865
  if (this.applyObj(x, y)) {
2903
2866
  parent.okBtn(true);
@@ -2927,7 +2890,9 @@ var Selection = /** @class */ (function () {
2927
2890
  if (this.applyObj(x, y)) {
2928
2891
  parent.okBtn(true);
2929
2892
  if (allowUndoRedoPush) {
2893
+ var cursor_1 = parent.cursor;
2930
2894
  parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
2895
+ parent.cursor = cursor_1;
2931
2896
  }
2932
2897
  parent.notify('draw', { prop: 'setPrevActObj', onPropertyChange: false, value: { prevActObj: null } });
2933
2898
  }
@@ -2938,10 +2903,9 @@ var Selection = /** @class */ (function () {
2938
2903
  parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
2939
2904
  }
2940
2905
  }
2941
- if (parent.activeObj.shape && (parent.activeObj.shape === 'rectangle' ||
2942
- parent.activeObj.shape === 'ellipse' || parent.activeObj.shape === 'line' ||
2943
- parent.activeObj.shape === 'arrow' || parent.activeObj.shape === 'path' || parent.activeObj.shape === 'text' ||
2944
- parent.activeObj.shape === 'image')) {
2906
+ var shape = parent.activeObj.shape;
2907
+ var shapeColl = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'text', 'image'];
2908
+ if (shape && shapeColl.indexOf(shape) > -1) {
2945
2909
  parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
2946
2910
  value: { x: null, y: null, isMouseDown: null } });
2947
2911
  parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
@@ -2967,7 +2931,9 @@ var Selection = /** @class */ (function () {
2967
2931
  if (this.applyObj(x_1, y_1)) {
2968
2932
  parent.okBtn(true);
2969
2933
  if (allowUndoRedoPush) {
2934
+ var cursor_2 = parent.cursor;
2970
2935
  parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
2936
+ parent.cursor = cursor_2;
2971
2937
  }
2972
2938
  parent.notify('draw', { prop: 'setPrevActObj', onPropertyChange: false, value: { prevActObj: null } });
2973
2939
  }
@@ -2993,6 +2959,7 @@ var Selection = /** @class */ (function () {
2993
2959
  }
2994
2960
  indexObj['freehandSelectedIndex'] = null;
2995
2961
  parent.notify('freehand-draw', { prop: 'getFreehandSelectedIndex', onPropertyChange: false, value: { obj: indexObj } });
2962
+ var objColl = extend([], parent.objColl, [], true);
2996
2963
  if (!isNullOrUndefined(obj['index']) && obj['index'] > -1) {
2997
2964
  parent.notify('freehand-draw', { prop: 'selectFhd', value: { type: 'ok' } });
2998
2965
  parent.notify('freehand-draw', { prop: 'hoverFhd', onPropertyChange: false,
@@ -3012,18 +2979,25 @@ var Selection = /** @class */ (function () {
3012
2979
  value: { strokeColor: strokeColor, strokeWidth: parent.pointColl[indexObj['freehandSelectedIndex']].strokeWidth } });
3013
2980
  }
3014
2981
  else if (this.findTargetObj(x_1, y_1, false)) {
2982
+ parent.objColl = objColl;
3015
2983
  this.findTarget(x_1, y_1, e.type);
2984
+ parent.notify('draw', { prop: 'redrawDownScale' });
3016
2985
  }
3017
2986
  }
3018
2987
  else {
3019
2988
  if (this.isFhdEditing) {
3020
2989
  parent.notify('freehand-draw', { prop: 'cancelFhd', value: { type: 'ok' } });
3021
- if (document.getElementById(parent.element.id + '_quickAccessToolbarArea')) {
3022
- document.getElementById(parent.element.id + '_quickAccessToolbarArea').style.display = 'none';
2990
+ var qbArea = document.getElementById(parent.element.id + '_quickAccessToolbarArea');
2991
+ if (qbArea) {
2992
+ qbArea.style.display = 'none';
3023
2993
  }
3024
2994
  }
3025
2995
  if (!isBlazor()) {
2996
+ var isPenDraw = parent.togglePen;
3026
2997
  parent.notify('toolbar', { prop: 'close-contextual-toolbar', onPropertyChange: false });
2998
+ if (isPenDraw) {
2999
+ parent.freehandDraw(true);
3000
+ }
3027
3001
  }
3028
3002
  this.isFhdEditing = false;
3029
3003
  if (isLineArrow) {
@@ -3032,13 +3006,11 @@ var Selection = /** @class */ (function () {
3032
3006
  else if (cursor !== 'default') {
3033
3007
  parent.upperCanvas.style.cursor = parent.cursor = cursor;
3034
3008
  }
3035
- // this.setCursor(x, y);
3036
3009
  if (parent.cursor === 'crosshair' || (Browser.isDevice && parent.togglePen)) {
3037
3010
  if (parent.togglePen) {
3038
3011
  if (isNullOrUndefined(parent.activeObj.strokeSettings)) {
3039
3012
  var obj_1 = { strokeSettings: {} };
3040
- parent.notify('shape', { prop: 'getStrokeSettings', onPropertyChange: false,
3041
- value: { obj: obj_1 } });
3013
+ parent.notify('shape', { prop: 'getStrokeSettings', onPropertyChange: false, value: { obj: obj_1 } });
3042
3014
  parent.activeObj.strokeSettings = obj_1['strokeSettings'];
3043
3015
  }
3044
3016
  var obj_2 = { penStrokeWidth: null };
@@ -3062,10 +3034,14 @@ var Selection = /** @class */ (function () {
3062
3034
  if ((parent.cursor !== 'crosshair' && e.type.toLowerCase() === 'touchstart') ||
3063
3035
  (parent.currObjType.isActiveObj && parent.cursor !== 'default' && !parent.togglePen)) {
3064
3036
  this.findTarget(x_1, y_1, e.type);
3037
+ parent.notify('draw', { prop: 'redrawDownScale' });
3065
3038
  }
3066
3039
  else if ((parent.currObjType.shape === '' || parent.currObjType.isCustomCrop) && !parent.togglePen && parent.cursor !== 'default') {
3067
3040
  this.setActivePoint(x_1, y_1);
3068
3041
  }
3042
+ if (isTextArea) {
3043
+ parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
3044
+ }
3069
3045
  }
3070
3046
  }
3071
3047
  this.isShapeInserted = false;
@@ -3076,6 +3052,9 @@ var Selection = /** @class */ (function () {
3076
3052
  var cursor = parent.cursor;
3077
3053
  var canvasCursor = parent.upperCanvas.style.cursor;
3078
3054
  e.preventDefault();
3055
+ if (this.timer && this.timer > 0) {
3056
+ this.timer = 0;
3057
+ }
3079
3058
  var bbox = parent.lowerCanvas.getBoundingClientRect();
3080
3059
  if (e.type === 'touchmove' && e.touches.length === 2) {
3081
3060
  if (this.isFirstMove) {
@@ -3109,7 +3088,7 @@ var Selection = /** @class */ (function () {
3109
3088
  }
3110
3089
  if (type !== '') {
3111
3090
  parent.notify('draw', { prop: 'performPointZoom', onPropertyChange: false,
3112
- value: { x: center.x, y: center.y, type: type } });
3091
+ value: { x: center.x, y: center.y, type: type, isResize: null } });
3113
3092
  }
3114
3093
  this.tempTouches = [];
3115
3094
  this.tempTouches.push({ x: e.touches[0].clientX || (e.touches[0].pageX - parent.lowerCanvas.offsetLeft),
@@ -3118,6 +3097,7 @@ var Selection = /** @class */ (function () {
3118
3097
  y: e.touches[1].clientY || (e.touches[1].pageY - parent.lowerCanvas.offsetTop) });
3119
3098
  this.currMousePoint.x = center.x;
3120
3099
  this.currMousePoint.y = center.y;
3100
+ this.isPinching = true;
3121
3101
  }
3122
3102
  }
3123
3103
  this.isFirstMove = false;
@@ -3164,15 +3144,16 @@ var Selection = /** @class */ (function () {
3164
3144
  this.findTarget(x, y, e.type);
3165
3145
  }
3166
3146
  }
3147
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
3167
3148
  if (parent.currObjType.isDragging) {
3168
3149
  this.upperContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
3169
3150
  this.updateActivePoint(x, y, isCropSelection);
3170
3151
  parent.notify('shape', { prop: 'updateTrianglePoints', onPropertyChange: false, value: { obj: parent.activeObj } });
3171
3152
  if (this.isPreventDragging) {
3172
- if ((parent.activeObj.activePoint.startX > parent.img.destLeft) &&
3173
- (parent.activeObj.activePoint.endX < parent.img.destLeft + parent.img.destWidth) &&
3174
- (parent.activeObj.activePoint.startY > parent.img.destTop)
3175
- && (parent.activeObj.activePoint.endY < parent.img.destTop + parent.img.destHeight)) {
3153
+ if ((parent.activeObj.activePoint.startX > destLeft) &&
3154
+ (parent.activeObj.activePoint.endX < destLeft + destWidth) &&
3155
+ (parent.activeObj.activePoint.startY > destTop)
3156
+ && (parent.activeObj.activePoint.endY < destTop + destHeight)) {
3176
3157
  this.isPreventDragging = false;
3177
3158
  }
3178
3159
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: null, isCropRatio: null,
@@ -3188,8 +3169,14 @@ var Selection = /** @class */ (function () {
3188
3169
  }
3189
3170
  };
3190
3171
  Selection.prototype.mouseUpEventHandler = function (e) {
3191
- var _this = this;
3192
3172
  var parent = this.parent;
3173
+ var id = parent.element.id;
3174
+ if (!Browser.isDevice && ((parent.element.querySelector('#' + id + '_contextualToolbar') &&
3175
+ !parent.element.querySelector('#' + id + '_contextualToolbar').parentElement.classList.contains('e-hide')) ||
3176
+ (parent.element.querySelector('#' + id + '_headWrapper')
3177
+ && !parent.element.querySelector('#' + id + '_headWrapper').parentElement.classList.contains('e-hide')))) {
3178
+ return;
3179
+ }
3193
3180
  if (e.type === 'touchstart') {
3194
3181
  this.isTouch = false;
3195
3182
  }
@@ -3219,6 +3206,19 @@ var Selection = /** @class */ (function () {
3219
3206
  if (parent.textArea.style.display === 'none') {
3220
3207
  this.timer = 0;
3221
3208
  }
3209
+ if (this.isPinching) {
3210
+ this.isPinching = false;
3211
+ parent.notify('draw', { prop: 'redrawDownScale' });
3212
+ if (parent.isCropTab || parent.activeObj.shape) {
3213
+ parent.notify('draw', { prop: 'setStraightenActObj', value: { activeObj: null } });
3214
+ parent.notify('freehand-draw', { prop: 'resetStraightenPoint' });
3215
+ }
3216
+ if (parent.isStraightening) {
3217
+ parent.notify('draw', { prop: 'resetStraightenDestPoints' });
3218
+ parent.notify('draw', { prop: 'setDestForStraighten' });
3219
+ }
3220
+ return;
3221
+ }
3222
3222
  }
3223
3223
  var isCropSelection = false;
3224
3224
  var splitWords;
@@ -3228,25 +3228,25 @@ var Selection = /** @class */ (function () {
3228
3228
  if (splitWords !== undefined && splitWords[0] === 'crop') {
3229
3229
  isCropSelection = true;
3230
3230
  }
3231
- if (isBlazor() && this.parent.eventType) {
3232
- if (this.parent.eventType === 'pan') {
3231
+ if (isBlazor() && parent.eventType) {
3232
+ if (parent.eventType === 'pan') {
3233
3233
  if (parent.events && parent.events.onPanEnd.hasDelegate === true) {
3234
- parent.dotNetRef.invokeMethodAsync('PanEventAsync', 'OnPanEnd', this.parent.panEventArgs);
3234
+ parent.dotNetRef.invokeMethodAsync('PanEventAsync', 'OnPanEnd', parent.panEventArgs);
3235
3235
  }
3236
3236
  }
3237
- else if (this.parent.eventType === 'resize') {
3238
- if (!this.isCropSelection && this.parent.events && this.parent.events.onShapeResizeEnd.hasDelegate === true) {
3237
+ else if (parent.eventType === 'resize') {
3238
+ if (!this.isCropSelection && parent.events && parent.events.onShapeResizeEnd.hasDelegate === true) {
3239
3239
  this.shapeResizingArgs.currentShapeSettings = this.updatePrevShapeSettings();
3240
3240
  this.shapeResizingArgs.action = this.currentDrawingShape !== '' ? 'drawing' : 'resize-end';
3241
3241
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3242
- this.parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShapeResizeEnd', this.shapeResizingArgs).then(function (shapeResizingArgs) {
3243
- _this.parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
3242
+ parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShapeResizeEnd', this.shapeResizingArgs, null).then(function (shapeResizingArgs) {
3243
+ parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
3244
3244
  value: { shapeSettings: shapeResizingArgs.currentShapeSettings } });
3245
3245
  });
3246
3246
  }
3247
- else if (this.shapeResizingArgs && this.selectionResizingArgs && this.parent.events &&
3248
- this.parent.events.onSelectionResizeEnd.hasDelegate === true) {
3249
- var currentSelectionSettings = { type: this.parent.activeObj.shape,
3247
+ else if (this.shapeResizingArgs && this.selectionResizingArgs && parent.events &&
3248
+ parent.events.onSelectionResizeEnd.hasDelegate === true) {
3249
+ var currentSelectionSettings = { type: parent.activeObj.shape,
3250
3250
  startX: this.shapeResizingArgs.currentShapeSettings.startX,
3251
3251
  startY: this.shapeResizingArgs.currentShapeSettings.startY,
3252
3252
  width: this.shapeResizingArgs.currentShapeSettings.width,
@@ -3254,36 +3254,38 @@ var Selection = /** @class */ (function () {
3254
3254
  this.selectionResizingArgs.currentSelectionSettings = currentSelectionSettings;
3255
3255
  this.selectionResizingArgs.action = 'resize-end';
3256
3256
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3257
- this.parent.dotNetRef.invokeMethodAsync('SelectionEventAsync', 'OnSelectionResizeEnd', this.selectionResizingArgs).then(function (selectionResizingArgs) {
3258
- _this.parent.notify('shape', { prop: 'updateSelectionChangeEventArgs', onPropertyChange: false,
3257
+ parent.dotNetRef.invokeMethodAsync('SelectionEventAsync', 'OnSelectionResizeEnd', this.selectionResizingArgs).then(function (selectionResizingArgs) {
3258
+ parent.notify('shape', { prop: 'updateSelectionChangeEventArgs', onPropertyChange: false,
3259
3259
  value: { selectionSettings: selectionResizingArgs.currentSelectionSettings } });
3260
3260
  });
3261
3261
  }
3262
3262
  }
3263
3263
  else {
3264
- if (this.shapeMovingArgs && this.parent.events && this.parent.events.onShapeDragEnd.hasDelegate === true) {
3264
+ if (this.shapeMovingArgs && parent.events && parent.events.onShapeDragEnd.hasDelegate === true) {
3265
3265
  this.shapeMovingArgs.currentShapeSettings = this.updatePrevShapeSettings();
3266
3266
  this.shapeMovingArgs.action = 'drag-end';
3267
3267
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3268
- this.parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShapeDragEnd', this.shapeMovingArgs).then(function (shapeMovingArgs) {
3269
- _this.parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
3268
+ parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShapeDragEnd', this.shapeMovingArgs, null).then(function (shapeMovingArgs) {
3269
+ parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
3270
3270
  value: { shapeSettings: shapeMovingArgs.currentShapeSettings } });
3271
3271
  });
3272
3272
  }
3273
3273
  }
3274
3274
  this.shapeResizingArgs = null;
3275
3275
  this.shapeMovingArgs = null;
3276
- this.parent.panEventArgs = null;
3277
- this.parent.eventType = null;
3276
+ parent.panEventArgs = null;
3277
+ parent.eventType = null;
3278
3278
  }
3279
3279
  if (this.currentDrawingShape === 'path') {
3280
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3280
3281
  var elem = e.srcElement;
3282
+ var elemId = elem.parentElement.id;
3283
+ var id_1 = parent.element.id;
3281
3284
  if (e.currentTarget !== parent.upperCanvas && e.currentTarget !== parent.lowerCanvas && parent.activeObj.pointColl.length > 0 &&
3282
- (elem.classList.contains('e-upload-icon') || elem.parentElement.id === parent.element.id + '_zoomIn' ||
3283
- elem.parentElement.id === parent.element.id + '_zoomOut' || elem.parentElement.id === parent.element.id + '_annotationBtn' ||
3284
- elem.parentElement.id === parent.element.id + '_borderColorBtn' || elem.parentElement.id === parent.element.id + '_borderWidthBtn' ||
3285
- elem.parentElement.id === parent.element.id + '_saveBtn')) {
3286
- this.parent.notify('shape', { prop: 'stopPathDrawing', onPropertyChange: false, value: { e: e, isApply: true } });
3285
+ (elem.classList.contains('e-upload-icon') || elemId === id_1 + '_zoomIn' ||
3286
+ elemId === id_1 + '_zoomOut' || elemId === id_1 + '_annotationBtn' ||
3287
+ elemId === id_1 + '_borderColorBtn' || elemId === id_1 + '_borderWidthBtn' || elemId === id_1 + '_saveBtn')) {
3288
+ parent.notify('shape', { prop: 'stopPathDrawing', onPropertyChange: false, value: { e: e, isApply: true } });
3287
3289
  this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
3288
3290
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj, isCropRatio: null,
3289
3291
  points: null, isPreventDrag: true, saveContext: null, isPreventSelection: true } });
@@ -3310,8 +3312,8 @@ var Selection = /** @class */ (function () {
3310
3312
  parent.notify('draw', { prop: 'performCancel', value: { isContextualToolbar: null } });
3311
3313
  }
3312
3314
  var previousShapeSettings = this.updatePrevShapeSettings();
3313
- var shapeResizingArgs = { action: 'draw-end', previousShapeSettings: previousShapeSettings };
3314
- var shapeMovingArgs = { action: 'move', previousShapeSettings: previousShapeSettings };
3315
+ var shapeResizingArgs = { cancel: false, action: 'draw-end', previousShapeSettings: previousShapeSettings };
3316
+ var shapeMovingArgs = { cancel: false, action: 'move', previousShapeSettings: previousShapeSettings };
3315
3317
  this.shapeResizingArgs = shapeResizingArgs;
3316
3318
  this.shapeMovingArgs = shapeMovingArgs;
3317
3319
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'mouse-up');
@@ -3332,6 +3334,7 @@ var Selection = /** @class */ (function () {
3332
3334
  prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
3333
3335
  if (!parent.togglePen && !isCropSelection) {
3334
3336
  if (this.tempObjColl && parent.activeObj.activePoint.width !== 0) {
3337
+ parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
3335
3338
  parent.objColl.push(parent.activeObj);
3336
3339
  if (JSON.stringify(parent.activeObj.activePoint) !== JSON.stringify(this.tempActiveObj.activePoint)) {
3337
3340
  parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
@@ -3363,13 +3366,14 @@ var Selection = /** @class */ (function () {
3363
3366
  else if (splitWords_1 !== undefined && splitWords_1[0] === 'crop') {
3364
3367
  isCropSelection_1 = true;
3365
3368
  }
3369
+ var shape = parent.activeObj.shape;
3366
3370
  if (!isBlazor()) {
3367
- if ((parent.activeObj.shape === 'rectangle') || (parent.activeObj.shape === 'ellipse')
3368
- || (parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow' || parent.activeObj.shape === 'path')) {
3371
+ var shapeColl = ['rectangle', 'ellipse', 'line', 'arrow', 'path'];
3372
+ if (shapeColl.indexOf(shape) > -1) {
3369
3373
  parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'shapes',
3370
3374
  isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
3371
3375
  }
3372
- else if (parent.activeObj.shape === 'text') {
3376
+ else if (shape === 'text') {
3373
3377
  if (parent.textArea.style.display === 'none') {
3374
3378
  parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'text',
3375
3379
  isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
@@ -3386,9 +3390,8 @@ var Selection = /** @class */ (function () {
3386
3390
  parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
3387
3391
  }
3388
3392
  else {
3389
- if ((parent.activeObj.shape === 'rectangle') || (parent.activeObj.shape === 'ellipse')
3390
- || (parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow' || parent.activeObj.shape === 'path'
3391
- || parent.activeObj.shape === 'image')) {
3393
+ var shapeColl = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'image'];
3394
+ if (shapeColl.indexOf(shape) > -1) {
3392
3395
  parent.updateToolbar(parent.element, parent.activeObj.shape);
3393
3396
  }
3394
3397
  else if (parent.activeObj.shape === 'text' && parent.textArea.style.display === 'none') {
@@ -3457,7 +3460,6 @@ var Selection = /** @class */ (function () {
3457
3460
  if (parent.activeObj.shape !== 'path') {
3458
3461
  parent.notify('shape', { prop: 'setPointCollForLineArrow', onPropertyChange: false,
3459
3462
  value: { obj: obj } });
3460
- // Updating ratio for point collection
3461
3463
  for (var i = 0; i < obj.pointColl.length; i++) {
3462
3464
  obj.pointColl[i].ratioX = (obj.pointColl[i].x -
3463
3465
  parent.img.destLeft) / parent.img.destWidth;
@@ -3472,33 +3474,17 @@ var Selection = /** @class */ (function () {
3472
3474
  var parent = this.parent;
3473
3475
  obj = obj ? obj : parent.activeObj;
3474
3476
  if (obj.shape && obj.rotatedAngle !== 0) {
3475
- parent.notify('shape', { prop: 'setPointCollForShapeRotation', onPropertyChange: false,
3476
- value: { obj: obj } });
3477
- // Updating ratio for point collection
3478
- for (var i = 0; i < obj.horTopLinePointColl.length; i++) {
3479
- obj.horTopLinePointColl[i].ratioX = (obj.horTopLinePointColl[i].x -
3480
- parent.img.destLeft) / parent.img.destWidth;
3481
- obj.horTopLinePointColl[i].ratioY = (obj.horTopLinePointColl[i].y -
3482
- parent.img.destTop) / parent.img.destHeight;
3483
- }
3484
- for (var i = 0; i < obj.horBottomLinePointColl.length; i++) {
3485
- obj.horBottomLinePointColl[i].ratioX = (obj.horBottomLinePointColl[i].x -
3486
- parent.img.destLeft) / parent.img.destWidth;
3487
- obj.horBottomLinePointColl[i].ratioY = (obj.horBottomLinePointColl[i].y -
3488
- parent.img.destTop) / parent.img.destHeight;
3489
- }
3490
- for (var i = 0; i < obj.verLeftLinePointColl.length; i++) {
3491
- obj.verLeftLinePointColl[i].ratioX = (obj.verLeftLinePointColl[i].x -
3492
- parent.img.destLeft) / parent.img.destWidth;
3493
- obj.verLeftLinePointColl[i].ratioY = (obj.verLeftLinePointColl[i].y -
3494
- parent.img.destTop) / parent.img.destHeight;
3495
- }
3496
- for (var i = 0; i < obj.verRightLinePointColl.length; i++) {
3497
- obj.verRightLinePointColl[i].ratioX = (obj.verRightLinePointColl[i].x -
3498
- parent.img.destLeft) / parent.img.destWidth;
3499
- obj.verRightLinePointColl[i].ratioY = (obj.verRightLinePointColl[i].y -
3500
- parent.img.destTop) / parent.img.destHeight;
3501
- }
3477
+ parent.notify('shape', { prop: 'setPointCollForShapeRotation', onPropertyChange: false, value: { obj: obj } });
3478
+ var _a = parent.img, destLeft_1 = _a.destLeft, destTop_1 = _a.destTop, destWidth_1 = _a.destWidth, destHeight_1 = _a.destHeight;
3479
+ var horTopLinePointColl = obj.horTopLinePointColl, horBottomLinePointColl = obj.horBottomLinePointColl, verLeftLinePointColl = obj.verLeftLinePointColl, verRightLinePointColl = obj.verRightLinePointColl;
3480
+ var setRatio = function (point) {
3481
+ point.ratioX = (point.x - destLeft_1) / destWidth_1;
3482
+ point.ratioY = (point.y - destTop_1) / destHeight_1;
3483
+ };
3484
+ horTopLinePointColl.forEach(setRatio);
3485
+ horBottomLinePointColl.forEach(setRatio);
3486
+ verLeftLinePointColl.forEach(setRatio);
3487
+ verRightLinePointColl.forEach(setRatio);
3502
3488
  }
3503
3489
  };
3504
3490
  Selection.prototype.setXYPoints = function (e) {
@@ -3521,7 +3507,7 @@ var Selection = /** @class */ (function () {
3521
3507
  Selection.prototype.getCurrentIndex = function () {
3522
3508
  var index;
3523
3509
  var parent = this.parent;
3524
- for (var i = 0; i < parent.objColl.length; i++) {
3510
+ for (var i = 0, len = parent.objColl.length; i < len; i++) {
3525
3511
  if (parent.activeObj.currIndex === parent.objColl[i].currIndex) {
3526
3512
  index = i;
3527
3513
  break;
@@ -3536,7 +3522,8 @@ var Selection = /** @class */ (function () {
3536
3522
  return isShape;
3537
3523
  }
3538
3524
  if (parent.activeObj.shape && parent.activeObj.shape === 'text' && this.isShapeInserted) {
3539
- var isTextArea = parent.textArea.style.display === 'block' ? true : false;
3525
+ var isTextArea = (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block')
3526
+ ? true : false;
3540
3527
  var activeObj = extend({}, parent.activeObj, null, true);
3541
3528
  parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
3542
3529
  value: { x: null, y: null, isMouseDown: true } });
@@ -3584,7 +3571,8 @@ var Selection = /** @class */ (function () {
3584
3571
  if (parent.activeObj && parent.activeObj.shape === 'text') {
3585
3572
  this.timer = setTimeout(this.setTimer.bind(this), 1000, e);
3586
3573
  }
3587
- var isTextArea = parent.textArea.style.display === 'block' ? true : false;
3574
+ var isTextArea = (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block')
3575
+ ? true : false;
3588
3576
  var activeObj = extend({}, parent.activeObj, null, true);
3589
3577
  parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
3590
3578
  value: { x: null, y: null, isMouseDown: true } });
@@ -3620,7 +3608,6 @@ var Selection = /** @class */ (function () {
3620
3608
  }
3621
3609
  }
3622
3610
  }
3623
- // this.timer = null;
3624
3611
  }
3625
3612
  return isShape;
3626
3613
  };
@@ -3628,7 +3615,8 @@ var Selection = /** @class */ (function () {
3628
3615
  var parent = this.parent;
3629
3616
  var isFreehandDraw = false;
3630
3617
  if (e.type === 'touchstart' && !isCropSelection && !parent.togglePen) {
3631
- var isTextArea = parent.textArea.style.display === 'block' ? true : false;
3618
+ var isTextArea = (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block')
3619
+ ? true : false;
3632
3620
  var activeObj = extend({}, parent.activeObj, null, true);
3633
3621
  parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
3634
3622
  value: { x: null, y: null, isMouseDown: true } });
@@ -3670,13 +3658,12 @@ var Selection = /** @class */ (function () {
3670
3658
  Selection.prototype.applyObj = function (x, y) {
3671
3659
  var parent = this.parent;
3672
3660
  var isApply = false;
3673
- if (parent.activeObj.shape && (parent.activeObj.shape === 'rectangle' || parent.activeObj.shape === 'ellipse' ||
3674
- parent.activeObj.shape === 'text' || parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow' ||
3675
- parent.activeObj.shape === 'path' || parent.activeObj.shape === 'image')) {
3676
- if (x >= (parent.activeObj.activePoint.startX - (parent.activeObj.topLeftCircle.radius * 2)) &&
3677
- x <= (parent.activeObj.activePoint.endX + (parent.activeObj.topLeftCircle.radius * 2)) &&
3678
- y >= (parent.activeObj.activePoint.startY - (parent.activeObj.topLeftCircle.radius * 2)) &&
3679
- y <= (parent.activeObj.activePoint.endY + (parent.activeObj.topLeftCircle.radius * 2))) {
3661
+ var shapeColl = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'image', 'text'];
3662
+ var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
3663
+ if (parent.activeObj.shape && shapeColl.indexOf(parent.activeObj.shape) > -1) {
3664
+ var radius = parent.activeObj.topLeftCircle.radius;
3665
+ if (x >= (startX - (radius * 2)) && x <= (endX + (radius * 2)) && y >= (startY - (radius * 2)) &&
3666
+ y <= (endY + (radius * 2))) {
3680
3667
  isApply = false;
3681
3668
  }
3682
3669
  else if (parent.upperCanvas.style.cursor !== 'default' && parent.upperCanvas.style.cursor !== 'grab' &&
@@ -3701,7 +3688,7 @@ var Selection = /** @class */ (function () {
3701
3688
  this.isInitialTextEdited = true;
3702
3689
  parent.notify('draw', { prop: 'setShapeTextInsert', onPropertyChange: false, value: { bool: true } });
3703
3690
  }
3704
- if (parent.textArea.style.display === 'block') {
3691
+ if (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') {
3705
3692
  var activeObj = extend({}, parent.activeObj, null, true);
3706
3693
  parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
3707
3694
  value: { x: null, y: null, isMouseDown: null } });
@@ -3711,7 +3698,7 @@ var Selection = /** @class */ (function () {
3711
3698
  parent.textArea.value = obj.keyHistory;
3712
3699
  parent.textArea.style.display = 'block';
3713
3700
  var strokeColor = obj.strokeSettings && obj.strokeSettings.strokeColor ? obj.strokeSettings.strokeColor.split('(')[0] === 'rgb' ?
3714
- this.rgbToHex(parseFloat(obj.strokeSettings.strokeColor.split('(')[1].split(',')[0]), parseFloat(obj.strokeSettings.strokeColor.split('(')[1].split(',')[1]), parseFloat(obj.strokeSettings.strokeColor.split('(')[1].split(',')[2])) :
3701
+ this.rgbToHex(parseFloat(obj.strokeSettings.strokeColor.split('(')[1].split(',')[0]), parseFloat(obj.strokeSettings.strokeColor.split('(')[1].split(',')[1]), parseFloat(obj.strokeSettings.strokeColor.split('(')[1].split(',')[2]), parseFloat(obj.strokeSettings.strokeColor.split('(')[1].split(',')[3])) :
3715
3702
  obj.strokeSettings.strokeColor : null;
3716
3703
  if (strokeColor && strokeColor === '#ffffff') {
3717
3704
  strokeColor = '#fff';
@@ -3798,6 +3785,10 @@ var Selection = /** @class */ (function () {
3798
3785
  parent.notify('transform', { prop: 'setPanMove', onPropertyChange: false,
3799
3786
  value: { point: { x: x, y: y } } });
3800
3787
  if (this.panDown && panMove && parent.togglePan && this.dragCanvas) {
3788
+ if (parent.isCropTab || parent.activeObj.shape) {
3789
+ parent.notify('draw', { prop: 'setStraightenActObj', value: { activeObj: null } });
3790
+ parent.notify('freehand-draw', { prop: 'resetStraightenPoint' });
3791
+ }
3801
3792
  parent.notify('transform', { prop: 'drawPannedImage', onPropertyChange: false,
3802
3793
  value: { xDiff: null, yDiff: null } });
3803
3794
  }
@@ -3823,12 +3814,13 @@ var Selection = /** @class */ (function () {
3823
3814
  };
3824
3815
  Selection.prototype.touchStartHandler = function (e) {
3825
3816
  e.preventDefault();
3817
+ var parent = this.parent;
3826
3818
  if (this.touchTime === 0) {
3827
3819
  this.touchTime = new Date().getTime();
3828
3820
  }
3829
3821
  else {
3830
3822
  if (((new Date().getTime()) - this.touchTime) < 400) {
3831
- this.parent.notify('shape', { prop: 'stopPathDrawing', onPropertyChange: false, value: { e: e, isApply: null } });
3823
+ parent.notify('shape', { prop: 'stopPathDrawing', onPropertyChange: false, value: { e: e, isApply: null } });
3832
3824
  this.touchTime = 0;
3833
3825
  }
3834
3826
  else {
@@ -3841,16 +3833,17 @@ var Selection = /** @class */ (function () {
3841
3833
  else {
3842
3834
  this.mouseDownEventHandler(e);
3843
3835
  }
3844
- EventHandler.add(this.parent.lowerCanvas, 'touchend', this.mouseUpEventHandler, this);
3845
- EventHandler.add(this.parent.lowerCanvas, 'touchmove', this.mouseMoveEventHandler, this);
3846
- EventHandler.add(this.parent.upperCanvas, 'touchend', this.mouseUpEventHandler, this);
3847
- EventHandler.add(this.parent.upperCanvas, 'touchmove', this.mouseMoveEventHandler, this);
3836
+ EventHandler.add(parent.lowerCanvas, 'touchend', this.mouseUpEventHandler, this);
3837
+ EventHandler.add(parent.lowerCanvas, 'touchmove', this.mouseMoveEventHandler, this);
3838
+ EventHandler.add(parent.upperCanvas, 'touchend', this.mouseUpEventHandler, this);
3839
+ EventHandler.add(parent.upperCanvas, 'touchmove', this.mouseMoveEventHandler, this);
3848
3840
  };
3849
3841
  Selection.prototype.unwireEvent = function () {
3850
- EventHandler.remove(this.parent.lowerCanvas, 'touchend', this.mouseUpEventHandler);
3851
- EventHandler.remove(this.parent.lowerCanvas, 'touchmove', this.mouseMoveEventHandler);
3852
- EventHandler.remove(this.parent.upperCanvas, 'touchend', this.mouseUpEventHandler);
3853
- EventHandler.remove(this.parent.upperCanvas, 'touchmove', this.mouseMoveEventHandler);
3842
+ var parent = this.parent;
3843
+ EventHandler.remove(parent.lowerCanvas, 'touchend', this.mouseUpEventHandler);
3844
+ EventHandler.remove(parent.lowerCanvas, 'touchmove', this.mouseMoveEventHandler);
3845
+ EventHandler.remove(parent.upperCanvas, 'touchend', this.mouseUpEventHandler);
3846
+ EventHandler.remove(parent.upperCanvas, 'touchmove', this.mouseMoveEventHandler);
3854
3847
  };
3855
3848
  Selection.prototype.keyDownEventHandler = function (e) {
3856
3849
  var _this = this;
@@ -3889,6 +3882,15 @@ var Selection = /** @class */ (function () {
3889
3882
  this.zoomType = 'Commands';
3890
3883
  parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
3891
3884
  value: { zoomFactor: .1, zoomPoint: null }, isResize: null });
3885
+ parent.notify('draw', { prop: 'redrawDownScale' });
3886
+ if (parent.isCropTab || parent.activeObj.shape) {
3887
+ parent.notify('draw', { prop: 'setStraightenActObj', value: { activeObj: null } });
3888
+ parent.notify('freehand-draw', { prop: 'resetStraightenPoint' });
3889
+ }
3890
+ if (parent.isStraightening) {
3891
+ parent.notify('draw', { prop: 'resetStraightenDestPoints' });
3892
+ parent.notify('draw', { prop: 'setDestForStraighten' });
3893
+ }
3892
3894
  }
3893
3895
  break;
3894
3896
  case (e.ctrlKey && '-'):
@@ -3896,6 +3898,15 @@ var Selection = /** @class */ (function () {
3896
3898
  this.zoomType = 'Commands';
3897
3899
  parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
3898
3900
  value: { zoomFactor: -.1, zoomPoint: null }, isResize: null });
3901
+ parent.notify('draw', { prop: 'redrawDownScale' });
3902
+ if (parent.isCropTab || parent.activeObj.shape) {
3903
+ parent.notify('draw', { prop: 'setStraightenActObj', value: { activeObj: null } });
3904
+ parent.notify('freehand-draw', { prop: 'resetStraightenPoint' });
3905
+ }
3906
+ if (parent.isStraightening) {
3907
+ parent.notify('draw', { prop: 'resetStraightenDestPoints' });
3908
+ parent.notify('draw', { prop: 'setDestForStraighten' });
3909
+ }
3899
3910
  }
3900
3911
  break;
3901
3912
  case 'Delete':
@@ -3911,7 +3922,7 @@ var Selection = /** @class */ (function () {
3911
3922
  this.performTabAction();
3912
3923
  break;
3913
3924
  default:
3914
- if (Browser.isDevice && parent.textArea.style.display === 'block') {
3925
+ if (Browser.isDevice && (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block')) {
3915
3926
  setTimeout(this.textKeyDown.bind(this), 1, e);
3916
3927
  }
3917
3928
  break;
@@ -3925,8 +3936,8 @@ var Selection = /** @class */ (function () {
3925
3936
  return;
3926
3937
  }
3927
3938
  var point = this.getNumTextValue();
3928
- var aspectRatioElement = this.parent.element.querySelector('#' + this.parent.element.id + '_aspectratio');
3929
- var blrAspRatElem = this.parent.element.querySelector('.e-ie-toolbar-aspect-ratio-btn');
3939
+ var aspectRatioElement = parent.element.querySelector('#' + parent.element.id + '_aspectratio');
3940
+ var blrAspRatElem = parent.element.querySelector('.e-ie-toolbar-aspect-ratio-btn');
3930
3941
  if (point && point.x && point.y) {
3931
3942
  if (aspectRatioElement || (blrAspRatElem && !blrAspRatElem.classList.contains('e-hidden'))) {
3932
3943
  parent.notify('transform', { prop: 'resize', value: { width: point.x, height: null, isAspectRatio: true } });
@@ -3936,16 +3947,16 @@ var Selection = /** @class */ (function () {
3936
3947
  }
3937
3948
  }
3938
3949
  if (isBlazor()) {
3939
- var aspectRatioHeight = this.parent.element.querySelector('.e-ie-toolbar-e-resize-height-input .e-numerictextbox');
3940
- var aspectRatioWidth = this.parent.element.querySelector('.e-ie-toolbar-e-resize-width-input .e-numerictextbox');
3950
+ var aspectRatioHeight = this.parent.element.querySelector('.e-ie-toolbar-e-resize-height-input .e-textbox');
3951
+ var aspectRatioWidth = this.parent.element.querySelector('.e-ie-toolbar-e-resize-width-input .e-textbox');
3941
3952
  if ((blrAspRatElem && blrAspRatElem.classList.contains('e-hidden'))) {
3942
3953
  if (aspectRatioHeight && aspectRatioHeight.value === "") {
3943
3954
  aspectRatioHeight.value = aspectRatioHeight.placeholder;
3944
- aspectRatioHeight.value = Math.floor(parent.img.destHeight).toString();
3955
+ aspectRatioHeight.value = aspectRatioHeight.placeholder;
3945
3956
  }
3946
3957
  if (aspectRatioWidth && aspectRatioWidth.value === "") {
3947
3958
  aspectRatioWidth.value = aspectRatioWidth.placeholder;
3948
- aspectRatioWidth.value = Math.floor(parent.img.destWidth).toString();
3959
+ aspectRatioWidth.value = aspectRatioWidth.placeholder;
3949
3960
  }
3950
3961
  }
3951
3962
  }
@@ -3955,20 +3966,21 @@ var Selection = /** @class */ (function () {
3955
3966
  if (isNullOrUndefined(aspectRatioElement)) {
3956
3967
  if (aspectRatioHeight) {
3957
3968
  var elem = getComponent(aspectRatioHeight, 'numerictextbox');
3958
- if (aspectRatioHeight && isNullOrUndefined(elem.value)) {
3969
+ if (aspectRatioHeight && aspectRatioHeight.value === '') {
3959
3970
  elem.value = parseFloat(elem.placeholder);
3960
- aspectRatioHeight.value = Math.floor(parent.img.destHeight).toString() + ' px';
3971
+ aspectRatioHeight.value = elem.placeholder + 'px';
3961
3972
  }
3962
3973
  }
3963
3974
  if (aspectRatioWidth) {
3964
3975
  var elem = getComponent(aspectRatioWidth, 'numerictextbox');
3965
- if (aspectRatioWidth && isNullOrUndefined(elem.value)) {
3976
+ if (aspectRatioWidth && aspectRatioWidth.value === '') {
3966
3977
  elem.value = parseFloat(elem.placeholder);
3967
- aspectRatioWidth.value = Math.floor(parent.img.destWidth).toString() + ' px';
3978
+ aspectRatioWidth.value = elem.placeholder + 'px';
3968
3979
  }
3969
3980
  }
3970
3981
  }
3971
3982
  }
3983
+ parent.notify('draw', { prop: 'redrawDownScale' });
3972
3984
  }
3973
3985
  else {
3974
3986
  var splitWords = void 0;
@@ -4038,12 +4050,24 @@ var Selection = /** @class */ (function () {
4038
4050
  }
4039
4051
  if (type !== '') {
4040
4052
  parent.notify('draw', { prop: 'performPointZoom', onPropertyChange: false,
4041
- value: { x: x, y: y, type: type } });
4053
+ value: { x: x, y: y, type: type, isResize: null } });
4054
+ parent.notify('draw', { prop: 'redrawDownScale' });
4055
+ if (parent.isCropTab || parent.activeObj.shape) {
4056
+ parent.notify('draw', { prop: 'setStraightenActObj', value: { activeObj: null } });
4057
+ parent.notify('freehand-draw', { prop: 'resetStraightenPoint' });
4058
+ }
4059
+ if (parent.isStraightening) {
4060
+ parent.notify('draw', { prop: 'resetStraightenDestPoints' });
4061
+ parent.notify('draw', { prop: 'setDestForStraighten' });
4062
+ }
4042
4063
  }
4043
4064
  }
4044
4065
  };
4045
4066
  Selection.prototype.textKeyDown = function (e) {
4046
4067
  var parent = this.parent;
4068
+ if (parent.activeObj.rotatedAngle !== 0) {
4069
+ return;
4070
+ }
4047
4071
  if (String.fromCharCode(e.which) === '\r') {
4048
4072
  this.textRow += 1;
4049
4073
  }
@@ -4076,33 +4100,33 @@ var Selection = /** @class */ (function () {
4076
4100
  Selection.prototype.setDragDirection = function (width, height) {
4077
4101
  var arcRadius = (7.5);
4078
4102
  var parent = this.parent;
4103
+ var actPoint = parent.activeObj.activePoint;
4079
4104
  if (parent.img.destWidth > parent.img.destHeight) {
4080
- parent.activeObj.activePoint.startX = this.dragPoint.startX = ((width / 2) - (height / 2))
4081
- + arcRadius;
4082
- parent.activeObj.activePoint.startY = this.dragPoint.startY = ((height / 2) - (height / 2))
4083
- + arcRadius;
4084
- parent.activeObj.activePoint.endX = ((width / 2) + (height / 2)) - arcRadius;
4085
- parent.activeObj.activePoint.endY = ((height / 2) + (height / 2)) - arcRadius;
4105
+ actPoint.startX = this.dragPoint.startX = ((width / 2) - (height / 2)) + arcRadius;
4106
+ actPoint.startY = this.dragPoint.startY = ((height / 2) - (height / 2)) + arcRadius;
4107
+ actPoint.endX = ((width / 2) + (height / 2)) - arcRadius;
4108
+ actPoint.endY = ((height / 2) + (height / 2)) - arcRadius;
4086
4109
  }
4087
4110
  else {
4088
- parent.activeObj.activePoint.startY = this.dragPoint.startX = ((height / 2) - (width) / 2)
4089
- + arcRadius;
4090
- parent.activeObj.activePoint.endY = ((height / 2) + (width) / 2) - arcRadius;
4091
- parent.activeObj.activePoint.startX = this.dragPoint.startX = arcRadius;
4092
- parent.activeObj.activePoint.endX = width - arcRadius;
4111
+ actPoint.startY = this.dragPoint.startX = ((height / 2) - (width) / 2) + arcRadius;
4112
+ actPoint.endY = ((height / 2) + (width) / 2) - arcRadius;
4113
+ actPoint.startX = this.dragPoint.startX = arcRadius;
4114
+ actPoint.endX = width - arcRadius;
4093
4115
  }
4094
4116
  };
4095
4117
  Selection.prototype.calcShapeRatio = function (x, y, imgWidth, imgHeight) {
4096
4118
  var parent = this.parent;
4119
+ var actPoint = parent.activeObj.activePoint;
4097
4120
  var arcRadius = (7.5);
4121
+ var presetRatio = x / y;
4098
4122
  var originalWidth = imgWidth;
4099
4123
  var originalHeight = imgHeight;
4100
- var presetRatio = x / y;
4101
4124
  var standardSize = originalWidth >= originalHeight ? originalWidth : originalHeight;
4102
4125
  var width = standardSize * presetRatio;
4103
4126
  var height = standardSize;
4104
4127
  var scaleWidth = this.getScale(width, originalWidth);
4105
4128
  var snippetArray = [];
4129
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
4106
4130
  for (var i = 0; i < 2; i++) {
4107
4131
  if (i === 0) {
4108
4132
  snippetArray.push(width * scaleWidth);
@@ -4125,24 +4149,22 @@ var Selection = /** @class */ (function () {
4125
4149
  }
4126
4150
  width = snippetArray1[0];
4127
4151
  height = snippetArray1[1];
4128
- parent.activeObj.activePoint.width = width;
4129
- parent.activeObj.activePoint.height = height;
4130
- parent.activeObj.activePoint.startX = (this.dragPoint.startX = (originalWidth - width) / 2) + arcRadius;
4131
- parent.activeObj.activePoint.startY = (this.dragPoint.startY = (originalHeight - height) / 2) + arcRadius;
4132
- parent.activeObj.activePoint.endX = ((originalWidth - width) / 2 + width) - arcRadius;
4133
- parent.activeObj.activePoint.endY = ((originalHeight - height) / 2 + height) - arcRadius;
4134
- if (parent.activeObj.activePoint.startX < parent.img.destLeft && parent.img.destLeft + parent.img.destWidth >
4135
- parent.lowerCanvas.clientWidth) {
4136
- parent.activeObj.activePoint.startX = parent.img.destLeft;
4137
- parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX + width - arcRadius;
4138
- }
4139
- if (parent.activeObj.activePoint.startY < parent.img.destTop && parent.img.destTop + parent.img.destHeight >
4140
- parent.lowerCanvas.clientHeight) {
4141
- parent.activeObj.activePoint.startY = parent.img.destTop;
4142
- parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY + height - arcRadius;
4143
- }
4144
- parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
4145
- parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
4152
+ actPoint.width = width;
4153
+ actPoint.height = height;
4154
+ actPoint.startX = (this.dragPoint.startX = (originalWidth - width) / 2) + arcRadius;
4155
+ actPoint.startY = (this.dragPoint.startY = (originalHeight - height) / 2) + arcRadius;
4156
+ actPoint.endX = ((originalWidth - width) / 2 + width) - arcRadius;
4157
+ actPoint.endY = ((originalHeight - height) / 2 + height) - arcRadius;
4158
+ if (actPoint.startX < destLeft && destLeft + destWidth > parent.lowerCanvas.clientWidth) {
4159
+ actPoint.startX = destLeft;
4160
+ actPoint.endX = actPoint.startX + width - arcRadius;
4161
+ }
4162
+ if (actPoint.startY < destTop && destTop + destHeight > parent.lowerCanvas.clientHeight) {
4163
+ actPoint.startY = destTop;
4164
+ actPoint.endY = actPoint.startY + height - arcRadius;
4165
+ }
4166
+ actPoint.width = actPoint.endX - actPoint.startX;
4167
+ actPoint.height = actPoint.endY - actPoint.startY;
4146
4168
  };
4147
4169
  Selection.prototype.getScale = function (value, originalValue) {
4148
4170
  return value > originalValue ? originalValue / value : 1;
@@ -4162,38 +4184,39 @@ var Selection = /** @class */ (function () {
4162
4184
  this.updateCursorStyles(x, y, type);
4163
4185
  }
4164
4186
  else {
4187
+ var _a = parent.activeObj, topLeftCircle = _a.topLeftCircle, topCenterCircle = _a.topCenterCircle, topRightCircle = _a.topRightCircle, centerLeftCircle = _a.centerLeftCircle, centerRightCircle = _a.centerRightCircle, bottomLeftCircle = _a.bottomLeftCircle, bottomCenterCircle = _a.bottomCenterCircle, bottomRightCircle = _a.bottomRightCircle;
4165
4188
  switch (this.dragElement.toLowerCase()) {
4166
4189
  case 'nw-resize':
4167
- parent.activeObj.topLeftCircle.startX = x;
4168
- parent.activeObj.topLeftCircle.startY = y;
4190
+ topLeftCircle.startX = x;
4191
+ topLeftCircle.startY = y;
4169
4192
  break;
4170
4193
  case 'n-resize':
4171
- parent.activeObj.topCenterCircle.startX = x;
4172
- parent.activeObj.topCenterCircle.startY = y;
4194
+ topCenterCircle.startX = x;
4195
+ topCenterCircle.startY = y;
4173
4196
  break;
4174
4197
  case 'ne-resize':
4175
- parent.activeObj.topRightCircle.startX = x;
4176
- parent.activeObj.topRightCircle.startY = y;
4198
+ topRightCircle.startX = x;
4199
+ topRightCircle.startY = y;
4177
4200
  break;
4178
4201
  case 'w-resize':
4179
- parent.activeObj.centerLeftCircle.startX = x;
4180
- parent.activeObj.centerLeftCircle.startY = y;
4202
+ centerLeftCircle.startX = x;
4203
+ centerLeftCircle.startY = y;
4181
4204
  break;
4182
4205
  case 'e-resize':
4183
- parent.activeObj.centerRightCircle.startX = x;
4184
- parent.activeObj.centerRightCircle.startY = y;
4206
+ centerRightCircle.startX = x;
4207
+ centerRightCircle.startY = y;
4185
4208
  break;
4186
4209
  case 'sw-resize':
4187
- parent.activeObj.bottomLeftCircle.startX = x;
4188
- parent.activeObj.bottomLeftCircle.startY = y;
4210
+ bottomLeftCircle.startX = x;
4211
+ bottomLeftCircle.startY = y;
4189
4212
  break;
4190
4213
  case 's-resize':
4191
- parent.activeObj.bottomCenterCircle.startX = x;
4192
- parent.activeObj.bottomCenterCircle.startY = y;
4214
+ bottomCenterCircle.startX = x;
4215
+ bottomCenterCircle.startY = y;
4193
4216
  break;
4194
4217
  case 'se-resize':
4195
- parent.activeObj.bottomRightCircle.startX = x;
4196
- parent.activeObj.bottomRightCircle.startY = y;
4218
+ bottomRightCircle.startX = x;
4219
+ bottomRightCircle.startY = y;
4197
4220
  break;
4198
4221
  default:
4199
4222
  if (this.dragPoint.startX && this.dragPoint.startY) {
@@ -4217,12 +4240,13 @@ var Selection = /** @class */ (function () {
4217
4240
  var cursor = parent.upperCanvas.style.cursor;
4218
4241
  this.setCursor(x, y);
4219
4242
  var actObj = extend({}, parent.objColl[index], {}, true);
4243
+ var radius = actObj.topLeftCircle.radius;
4220
4244
  if (actObj.shape === 'line' || actObj.shape === 'arrow') {
4221
4245
  for (var j = 0; j < actObj.pointColl.length; j++) {
4222
- if (x >= actObj.pointColl[j].x - (actObj.topLeftCircle.radius * 2) &&
4223
- x <= actObj.pointColl[j].x + (actObj.topLeftCircle.radius * 2) &&
4224
- y >= actObj.pointColl[j].y - (actObj.topLeftCircle.radius * 2) &&
4225
- y <= actObj.pointColl[j].y + (actObj.topLeftCircle.radius * 2)) {
4246
+ if (x >= actObj.pointColl[j].x - (radius * 2) &&
4247
+ x <= actObj.pointColl[j].x + (radius * 2) &&
4248
+ y >= actObj.pointColl[j].y - (radius * 2) &&
4249
+ y <= actObj.pointColl[j].y + (radius * 2)) {
4226
4250
  if (this.tempActiveObj && this.tempActiveObj.activePoint &&
4227
4251
  JSON.stringify(this.tempActiveObj.activePoint) === JSON.stringify(actObj.activePoint)) {
4228
4252
  i = index;
@@ -4245,8 +4269,8 @@ var Selection = /** @class */ (function () {
4245
4269
  }
4246
4270
  }
4247
4271
  else if (actObj.shape === 'path') {
4248
- var cursor_1 = this.setCursorForPath(actObj, x, y, parent.upperCanvas);
4249
- if (cursor_1 !== 'default' && cursor_1 !== 'grab') {
4272
+ var cursor_3 = this.setCursorForPath(actObj, x, y, parent.upperCanvas);
4273
+ if (cursor_3 !== 'default' && cursor_3 !== 'grab') {
4250
4274
  if (this.tempActiveObj && this.tempActiveObj.activePoint &&
4251
4275
  JSON.stringify(this.tempActiveObj.activePoint) === JSON.stringify(actObj.activePoint)) {
4252
4276
  i = index;
@@ -4266,8 +4290,8 @@ var Selection = /** @class */ (function () {
4266
4290
  }
4267
4291
  }
4268
4292
  else if (actObj.rotatedAngle !== 0) {
4269
- var cursor_2 = this.setCursorForRotatedObject(actObj, x, y, parent.upperCanvas);
4270
- if (cursor_2 !== 'default' && cursor_2 !== 'grab') {
4293
+ var cursor_4 = this.setCursorForRotatedObject(actObj, x, y, parent.upperCanvas);
4294
+ if (cursor_4 !== 'default' && cursor_4 !== 'grab') {
4271
4295
  if (this.tempActiveObj && this.tempActiveObj.activePoint &&
4272
4296
  JSON.stringify(this.tempActiveObj.activePoint) === JSON.stringify(actObj.activePoint)) {
4273
4297
  i = index;
@@ -4288,15 +4312,15 @@ var Selection = /** @class */ (function () {
4288
4312
  }
4289
4313
  else {
4290
4314
  var rotationCirclePoint = this.getTransRotationPoint(actObj);
4291
- if ((x >= (actObj.activePoint.startX - (actObj.topLeftCircle.radius * 2)) &&
4292
- x <= (actObj.activePoint.endX + (actObj.topLeftCircle.radius * 2)) &&
4293
- y >= (actObj.activePoint.startY - (actObj.topLeftCircle.radius * 2)) &&
4294
- y <= (actObj.activePoint.endY + (actObj.topLeftCircle.radius * 2))) ||
4315
+ if ((x >= (actObj.activePoint.startX - (radius * 2)) &&
4316
+ x <= (actObj.activePoint.endX + (radius * 2)) &&
4317
+ y >= (actObj.activePoint.startY - (radius * 2)) &&
4318
+ y <= (actObj.activePoint.endY + (radius * 2))) ||
4295
4319
  (rotationCirclePoint &&
4296
- x >= (rotationCirclePoint.x - (actObj.topLeftCircle.radius * 2)) &&
4297
- x <= (rotationCirclePoint.x + (actObj.topLeftCircle.radius * 2)) &&
4298
- y >= (rotationCirclePoint.y - (actObj.topLeftCircle.radius * 2)) &&
4299
- y <= (rotationCirclePoint.y + (actObj.topLeftCircle.radius * 2)))) {
4320
+ x >= (rotationCirclePoint.x - (radius * 2)) &&
4321
+ x <= (rotationCirclePoint.x + (radius * 2)) &&
4322
+ y >= (rotationCirclePoint.y - (radius * 2)) &&
4323
+ y <= (rotationCirclePoint.y + (radius * 2)))) {
4300
4324
  if (this.tempActiveObj && this.tempActiveObj.activePoint &&
4301
4325
  JSON.stringify(this.tempActiveObj.activePoint) === JSON.stringify(actObj.activePoint)) {
4302
4326
  i = index;
@@ -4358,7 +4382,7 @@ var Selection = /** @class */ (function () {
4358
4382
  var tempTextSettings = extend({}, parent.activeObj.textSettings, {}, true);
4359
4383
  parent.notify('draw', { prop: 'setTempTextSettings', onPropertyChange: false, value: { tempTextSettings: tempTextSettings } });
4360
4384
  var shapeSettings = this.updatePrevShapeSettings();
4361
- var shapeChangingArgs_1 = { action: 'select', previousShapeSettings: shapeSettings,
4385
+ var shapeChangingArgs_1 = { cancel: false, action: 'select', previousShapeSettings: shapeSettings,
4362
4386
  currentShapeSettings: shapeSettings };
4363
4387
  if (parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow') {
4364
4388
  shapeChangingArgs_1.currentShapeSettings.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
@@ -4372,10 +4396,10 @@ var Selection = /** @class */ (function () {
4372
4396
  if (splitWords !== undefined && splitWords[0] === 'crop') {
4373
4397
  this.isCropSelection = true;
4374
4398
  }
4375
- if (!this.isCropSelection && isBlazor() && isNullOrUndefined(this.parent.eventType) &&
4399
+ if (!this.isCropSelection && isBlazor() && isNullOrUndefined(parent.eventType) &&
4376
4400
  parent.events && parent.events.shapeChanging.hasDelegate === true) {
4377
4401
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4378
- parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs_1).then(function (shapeChangingArgs) {
4402
+ parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs_1, null).then(function (shapeChangingArgs) {
4379
4403
  _this.shapeEvent(shapeChangingArgs);
4380
4404
  });
4381
4405
  }
@@ -4415,6 +4439,16 @@ var Selection = /** @class */ (function () {
4415
4439
  }
4416
4440
  }
4417
4441
  isShape = true;
4442
+ if (isBlazor()) {
4443
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4444
+ var tempCursor = parent.upperCanvas.style.cursor;
4445
+ this.setCursor(x, y);
4446
+ if (shapeChangingArgs_1.action === 'select' && parent.upperCanvas.style.cursor === 'move') {
4447
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4448
+ parent.getShapeValue(parent.activeObj.shape);
4449
+ }
4450
+ parent.upperCanvas.style.cursor = tempCursor;
4451
+ }
4418
4452
  }
4419
4453
  }
4420
4454
  return isShape;
@@ -4437,18 +4471,13 @@ var Selection = /** @class */ (function () {
4437
4471
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj, isCropRatio: null,
4438
4472
  points: null, isPreventDrag: true, saveContext: null, isPreventSelection: true } });
4439
4473
  if (!this.isShapeInserted) {
4440
- if (parent.activeObj.activePoint.startX < parent.img.destLeft) {
4441
- this.isPreventDragging = true;
4442
- }
4443
- else if (parent.activeObj.activePoint.endX > parent.img.destLeft + parent.img.destWidth) {
4444
- this.isPreventDragging = true;
4445
- }
4446
- else if (parent.activeObj.activePoint.startY < parent.img.destTop) {
4447
- this.isPreventDragging = true;
4448
- }
4449
- else if (parent.activeObj.activePoint.endY > parent.img.destTop + parent.img.destHeight) {
4450
- this.isPreventDragging = true;
4451
- }
4474
+ var activePoint = parent.activeObj.activePoint;
4475
+ var _a = parent.img, destLeft = _a.destLeft, destWidth = _a.destWidth, destTop = _a.destTop, destHeight = _a.destHeight;
4476
+ this.isPreventDragging =
4477
+ activePoint.startX < destLeft ||
4478
+ activePoint.endX > destLeft + destWidth ||
4479
+ activePoint.startY < destTop ||
4480
+ activePoint.endY > destTop + destHeight;
4452
4481
  }
4453
4482
  }
4454
4483
  };
@@ -4457,14 +4486,35 @@ var Selection = /** @class */ (function () {
4457
4486
  var activeObj = extend({}, parent.activeObj, null, true);
4458
4487
  var ctx = parent.activeObj.imageCanvas.getContext('2d');
4459
4488
  var dimObj = { width: 0, height: 0 };
4460
- parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
4461
- value: { width: parent.activeObj.imageElement.width, height: parent.activeObj.imageElement.height, obj: dimObj, isImgShape: null } });
4489
+ parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false, value: { width: parent.activeObj.imageElement.width,
4490
+ height: parent.activeObj.imageElement.height, obj: dimObj, isImgShape: null } });
4462
4491
  parent.notify('shape', { prop: 'updateObj', onPropertyChange: false, value: { dimObj: dimObj, x: null, y: null } });
4463
4492
  ctx.clearRect(0, 0, parent.activeObj.imageCanvas.width, parent.activeObj.imageCanvas.height);
4464
- parent.notify('draw', { prop: 'downScaleImgCanvas', onPropertyChange: false,
4465
- value: { ctx: ctx, isImgAnnotation: true, isHFlip: null, isVFlip: null } });
4493
+ this.applyTransformToImg(ctx);
4466
4494
  parent.activeObj = activeObj;
4467
4495
  };
4496
+ Selection.prototype.applyTransformToImg = function (ctx) {
4497
+ var parent = this.parent;
4498
+ if (parent.activeObj.isHorImageFlip && parent.activeObj.isVerImageFlip) {
4499
+ parent.activeObj.isHorImageFlip = parent.activeObj.isVerImageFlip = false;
4500
+ parent.notify('draw', { prop: 'downScaleImgCanvas', onPropertyChange: false,
4501
+ value: { ctx: ctx, isImgAnnotation: true, isHFlip: true, isVFlip: true } });
4502
+ }
4503
+ else if (parent.activeObj.isHorImageFlip) {
4504
+ parent.activeObj.isHorImageFlip = false;
4505
+ parent.notify('draw', { prop: 'downScaleImgCanvas', onPropertyChange: false,
4506
+ value: { ctx: ctx, isImgAnnotation: true, isHFlip: true, isVFlip: false } });
4507
+ }
4508
+ else if (parent.activeObj.isVerImageFlip) {
4509
+ parent.activeObj.isVerImageFlip = false;
4510
+ parent.notify('draw', { prop: 'downScaleImgCanvas', onPropertyChange: false,
4511
+ value: { ctx: ctx, isImgAnnotation: true, isHFlip: false, isVFlip: true } });
4512
+ }
4513
+ else {
4514
+ parent.notify('draw', { prop: 'downScaleImgCanvas', onPropertyChange: false,
4515
+ value: { ctx: ctx, isImgAnnotation: true, isHFlip: false, isVFlip: false } });
4516
+ }
4517
+ };
4468
4518
  // eslint-disable-next-line
4469
4519
  Selection.prototype.targetTouches = function (touches) {
4470
4520
  var bbox = this.parent.lowerCanvas.getBoundingClientRect();
@@ -4521,12 +4571,13 @@ var Selection = /** @class */ (function () {
4521
4571
  }
4522
4572
  };
4523
4573
  Selection.prototype.setTimer = function (e) {
4574
+ var parent = this.parent;
4524
4575
  if (this.timer > 10) {
4525
4576
  clearTimeout(this.timer);
4526
4577
  this.timer = 0;
4527
- this.parent.notify('shape', { prop: 'findTextTarget', onPropertyChange: false, value: { e: e } });
4578
+ parent.notify('shape', { prop: 'findTextTarget', onPropertyChange: false, value: { e: e } });
4528
4579
  if (Browser.isDevice) {
4529
- this.upperContext.clearRect(0, 0, this.parent.upperCanvas.width, this.parent.upperCanvas.height);
4580
+ this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
4530
4581
  }
4531
4582
  }
4532
4583
  };
@@ -4537,17 +4588,13 @@ var Selection = /** @class */ (function () {
4537
4588
  if (isNullOrUndefined(actObj.activePoint)) {
4538
4589
  return;
4539
4590
  }
4591
+ var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
4540
4592
  var radius = actObj.topLeftCircle ? actObj.topLeftCircle.radius : 0;
4541
- if ((x >= Math.floor(actObj.activePoint.startX) &&
4542
- x <= Math.ceil(actObj.activePoint.endX) &&
4543
- y >= Math.floor(actObj.activePoint.startY) &&
4544
- y <= Math.ceil(actObj.activePoint.endY))) {
4593
+ if ((x >= Math.floor(startX) && x <= Math.ceil(endX) && y >= Math.floor(startY) && y <= Math.ceil(endY))) {
4545
4594
  isInside = true;
4546
4595
  }
4547
- else if (radius !== 0 && (x >= Math.floor(actObj.activePoint.startX) - radius &&
4548
- x <= Math.ceil(actObj.activePoint.endX) + radius &&
4549
- y >= Math.floor(actObj.activePoint.startY) - radius &&
4550
- y <= Math.ceil(actObj.activePoint.endY) + radius)) {
4596
+ else if (radius !== 0 && (x >= Math.floor(startX) - radius && x <= Math.ceil(endX) + radius &&
4597
+ y >= Math.floor(startY) - radius && y <= Math.ceil(endY) + radius)) {
4551
4598
  isInside = true;
4552
4599
  this.tempActiveObj = { activePoint: { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 },
4553
4600
  flipObjColl: [], triangle: [], triangleRatio: [] };
@@ -4556,12 +4603,8 @@ var Selection = /** @class */ (function () {
4556
4603
  isInside = true;
4557
4604
  }
4558
4605
  else if (actObj.shape === 'line' || actObj.shape === 'arrow') {
4559
- var smallPoint = { x: actObj.activePoint.startX < actObj.activePoint.endX ? actObj.activePoint.startX :
4560
- actObj.activePoint.endX,
4561
- y: actObj.activePoint.startY < actObj.activePoint.endY ? actObj.activePoint.startY : actObj.activePoint.endY };
4562
- var largePoint = { x: actObj.activePoint.startX > actObj.activePoint.endX ? actObj.activePoint.startX :
4563
- actObj.activePoint.endX,
4564
- y: actObj.activePoint.startY > actObj.activePoint.endY ? actObj.activePoint.startY : actObj.activePoint.endY };
4606
+ var smallPoint = { x: startX < endX ? startX : endX, y: startY < endY ? startY : endY };
4607
+ var largePoint = { x: startX > endX ? startX : endX, y: startY > endY ? startY : endY };
4565
4608
  if (x >= (Math.floor(smallPoint.x) - 5) && x <= (Math.ceil(largePoint.x) + 5) &&
4566
4609
  y >= (Math.floor(smallPoint.y) - 5) && y <= (Math.ceil(largePoint.y) + 5)) {
4567
4610
  isInside = true;
@@ -4583,7 +4626,7 @@ var Selection = /** @class */ (function () {
4583
4626
  isInside = true;
4584
4627
  }
4585
4628
  }
4586
- else if (parent.textArea.style.display === 'block') {
4629
+ else if (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') {
4587
4630
  isInside = true;
4588
4631
  }
4589
4632
  if (!isInside) {
@@ -4595,9 +4638,8 @@ var Selection = /** @class */ (function () {
4595
4638
  !== 0 && !parent.currObjType.isCustomCrop && parent.currObjType.shape !== '') {
4596
4639
  parent.objColl.push(extend({}, parent.activeObj, {}, true));
4597
4640
  }
4598
- if (parent.activeObj.shape === 'text' || (parent.currObjType.shape === 'ellipse' || parent.currObjType.shape === 'rectangle' ||
4599
- parent.currObjType.shape === 'line' || parent.activeObj.shape === 'arrow' || parent.activeObj.shape === 'path' ||
4600
- parent.activeObj.shape === 'image')) {
4641
+ var shapeColl = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'text', 'image'];
4642
+ if (shapeColl.indexOf(parent.activeObj.shape) > -1) {
4601
4643
  var tempFilter = this.lowerContext.filter;
4602
4644
  this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
4603
4645
  'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' +
@@ -4646,8 +4688,9 @@ var Selection = /** @class */ (function () {
4646
4688
  parent.activeObj.textSettings.fontFamily = parent.textArea.style.fontFamily;
4647
4689
  parent.activeObj.strokeSettings.strokeColor = parent.textArea.style.color !== '' &&
4648
4690
  parent.textArea.style.color.split('(')[1] && parent.textArea.style.color.split('(')[1].split(',')[0] &&
4649
- parent.textArea.style.color.split('(')[1].split(',')[1] && parent.textArea.style.color.split('(')[1].split(',')[2] ?
4650
- this.rgbToHex(parseFloat(parent.textArea.style.color.split('(')[1].split(',')[0]), parseFloat(parent.textArea.style.color.split('(')[1].split(',')[1]), parseFloat(parent.textArea.style.color.split('(')[1].split(',')[2])) :
4691
+ parent.textArea.style.color.split('(')[1].split(',')[1] && parent.textArea.style.color.split('(')[1].split(',')[2]
4692
+ && parent.textArea.style.color.split('(')[1].split(',')[3] ?
4693
+ this.rgbToHex(parseFloat(parent.textArea.style.color.split('(')[1].split(',')[0]), parseFloat(parent.textArea.style.color.split('(')[1].split(',')[1]), parseFloat(parent.textArea.style.color.split('(')[1].split(',')[2]), parseFloat(parent.textArea.style.color.split('(')[1].split(',')[3])) :
4651
4694
  parent.textArea.style.color;
4652
4695
  if (parent.textArea.style.fontWeight === 'bold') {
4653
4696
  parent.activeObj.textSettings.bold = true;
@@ -4663,16 +4706,27 @@ var Selection = /** @class */ (function () {
4663
4706
  }
4664
4707
  parent.activeObj.textSettings.fontSize = (parseFloat(parent.textArea.style.fontSize));
4665
4708
  };
4666
- Selection.prototype.rgbToHex = function (r, g, b) {
4667
- return '#' + this.componentToHex(r) + this.componentToHex(g) + this.componentToHex(b);
4709
+ Selection.prototype.rgbToHex = function (r, g, b, a) {
4710
+ r = Math.max(0, Math.min(255, Math.round(r)));
4711
+ g = Math.max(0, Math.min(255, Math.round(g)));
4712
+ b = Math.max(0, Math.min(255, Math.round(b)));
4713
+ a = Math.max(0, Math.min(1, a));
4714
+ var hexR = this.padLeft(r.toString(16), 2, '0');
4715
+ var hexG = this.padLeft(g.toString(16), 2, '0');
4716
+ var hexB = this.padLeft(b.toString(16), 2, '0');
4717
+ var hexA = this.padLeft(Math.round(a * 255).toString(16), 2, '0');
4718
+ var hex = "#" + hexR + hexG + hexB + hexA;
4719
+ return hex;
4668
4720
  };
4669
- Selection.prototype.componentToHex = function (rgb) {
4670
- var hex = rgb.toString(16);
4671
- return hex.length === 1 ? '0' + hex : hex;
4721
+ Selection.prototype.padLeft = function (value, length, padChar) {
4722
+ while (value.length < length) {
4723
+ value = padChar + value;
4724
+ }
4725
+ return value;
4672
4726
  };
4673
4727
  Selection.prototype.deleteItem = function () {
4674
4728
  var parent = this.parent;
4675
- var shapeChangingArgs = {};
4729
+ var shapeChangingArgs = { cancel: false };
4676
4730
  var previousShapeSettings = {};
4677
4731
  if (this.isFhdEditing) {
4678
4732
  this.updateFreehandDrawColorChange();
@@ -4708,7 +4762,7 @@ var Selection = /** @class */ (function () {
4708
4762
  if (obj['prevActObj'] && JSON.stringify(obj['prevActObj']) !== JSON.stringify(parent.activeObj)) {
4709
4763
  var index = parent.activeObj.currIndex;
4710
4764
  parent.notify('draw', { prop: 'performCancel', value: { isContextualToolbar: null } });
4711
- for (var i = 0; i < parent.objColl.length; i++) {
4765
+ for (var i = 0, len = parent.objColl.length; i < len; i++) {
4712
4766
  if (parent.objColl[i].currIndex === index) {
4713
4767
  parent.objColl.splice(i, 1);
4714
4768
  parent.notify('draw', { prop: 'render-image', value: { isMouseWheel: null } });
@@ -4744,11 +4798,11 @@ var Selection = /** @class */ (function () {
4744
4798
  prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
4745
4799
  parent.objColl.pop();
4746
4800
  previousShapeSettings = this.updatePrevShapeSettings();
4747
- shapeChangingArgs = { action: 'delete', previousShapeSettings: previousShapeSettings, currentShapeSettings: null };
4801
+ shapeChangingArgs = { cancel: false, action: 'delete', previousShapeSettings: previousShapeSettings, currentShapeSettings: null };
4748
4802
  parent.notify('shape', { prop: 'setKeyHistory', onPropertyChange: false, value: { keyHistory: '' } });
4749
4803
  parent.clearSelection();
4750
4804
  if (isBlazor() && parent.events && parent.events.shapeChanging.hasDelegate === true) {
4751
- parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs);
4805
+ parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs, null);
4752
4806
  }
4753
4807
  else {
4754
4808
  parent.trigger('shapeChanging', shapeChangingArgs);
@@ -4796,25 +4850,25 @@ var Selection = /** @class */ (function () {
4796
4850
  fontStyle.push('underline');
4797
4851
  }
4798
4852
  }
4853
+ var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
4854
+ var _b = parent.activeObj, keyHistory = _b.keyHistory, currIndex = _b.currIndex, shape = _b.shape, textSettings = _b.textSettings, strokeSettings = _b.strokeSettings, rotatedAngle = _b.rotatedAngle, imageElement = _b.imageElement, opacity = _b.opacity;
4799
4855
  var shapeSettingsObj = {
4800
- id: !isNullOrUndefined(parent.activeObj.currIndex) ? parent.activeObj.currIndex : null,
4801
- type: parent.toPascalCase(parent.activeObj.shape),
4802
- startX: parent.activeObj.activePoint.startX, startY: parent.activeObj.activePoint.startY,
4803
- width: parent.activeObj.activePoint.width, height: parent.activeObj.activePoint.height,
4804
- strokeColor: parent.activeObj.strokeSettings ? parent.activeObj.strokeSettings.strokeColor : null,
4805
- strokeWidth: parent.activeObj.strokeSettings ? parent.activeObj.strokeSettings.strokeWidth : null,
4806
- fillColor: parent.activeObj.strokeSettings ? parent.activeObj.strokeSettings.fillColor : null,
4807
- radius: parent.activeObj.shape === 'ellipse' ? parent.activeObj.activePoint.width / 2 : null,
4808
- length: parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow' ? parent.activeObj.activePoint.width : null,
4809
- text: parent.activeObj.shape === 'text' ? (parent.activeObj.keyHistory ? parent.activeObj.keyHistory :
4810
- (parent.activeObj.textSettings.text ? parent.activeObj.textSettings.text : null)) : null,
4811
- fontSize: parent.activeObj.shape === 'text' ? (parent.activeObj.textSettings ? parent.activeObj.textSettings.fontSize : null) : null,
4812
- fontFamily: parent.activeObj.shape === 'text' ? (parent.activeObj.textSettings ? parent.activeObj.textSettings.fontFamily : null) : null,
4813
- fontStyle: parent.activeObj.shape === 'text' ? fontStyle : null,
4814
- color: parent.activeObj.shape === 'text' ? (parent.activeObj.strokeSettings ? parent.activeObj.strokeSettings.strokeColor : null) : null,
4815
- degree: parent.activeObj.shape === 'ellipse' || parent.activeObj.shape === 'rectangle' || parent.activeObj.shape === 'image' ?
4816
- parent.activeObj.rotatedAngle * (180 / Math.PI) : null,
4817
- imageData: parent.activeObj.shape === 'image' ? parent.activeObj.imageElement.src : null
4856
+ id: !isNullOrUndefined(currIndex) ? currIndex : null,
4857
+ type: parent.toPascalCase(shape),
4858
+ startX: startX, startY: startY, width: width, height: height,
4859
+ strokeColor: strokeSettings ? strokeSettings.strokeColor : null,
4860
+ strokeWidth: strokeSettings ? strokeSettings.strokeWidth : null,
4861
+ fillColor: strokeSettings ? strokeSettings.fillColor : null,
4862
+ radius: shape === 'ellipse' ? width / 2 : null,
4863
+ length: shape === 'line' || shape === 'arrow' ? width : null,
4864
+ text: shape === 'text' ? (keyHistory ? keyHistory : (textSettings.text ? textSettings.text : null)) : null,
4865
+ fontSize: shape === 'text' ? (textSettings ? textSettings.fontSize : null) : null,
4866
+ fontFamily: shape === 'text' ? (textSettings ? textSettings.fontFamily : null) : null,
4867
+ fontStyle: shape === 'text' ? fontStyle : null,
4868
+ color: shape === 'text' ? (strokeSettings ? strokeSettings.strokeColor : null) : null,
4869
+ degree: shape === 'ellipse' || shape === 'rectangle' || shape === 'image' ? rotatedAngle * (180 / Math.PI) : null,
4870
+ imageData: shape === 'image' ? imageElement.src : null,
4871
+ opacity: shape === 'image' ? opacity : null
4818
4872
  };
4819
4873
  if (obj) {
4820
4874
  obj['shapeSettingsObj'] = shapeSettingsObj;
@@ -4833,13 +4887,12 @@ var Selection = /** @class */ (function () {
4833
4887
  var rotatedY = -localX * sinAngle + localY * cosAngle;
4834
4888
  var halfWidth = rectWidth / 2;
4835
4889
  var halfHeight = rectHeight / 2;
4836
- // Check if the rotated point is within the bounds of the rectangle
4837
4890
  if (rotatedX >= -halfWidth && rotatedX <= halfWidth && rotatedY >= -halfHeight &&
4838
4891
  rotatedY <= halfHeight) {
4839
- return true; // Point is inside the rotated rectangle
4892
+ return true;
4840
4893
  }
4841
4894
  else {
4842
- return false; // Point is outside the rotated rectangle
4895
+ return false;
4843
4896
  }
4844
4897
  };
4845
4898
  Selection.prototype.getTransRotationPoint = function (obj, object) {
@@ -4847,17 +4900,12 @@ var Selection = /** @class */ (function () {
4847
4900
  var degree;
4848
4901
  var isHorizontalflip = false;
4849
4902
  var isVerticalflip = false;
4850
- if (obj.shapeDegree === 0) {
4851
- degree = this.parent.transform.degree;
4852
- }
4853
- else {
4854
- degree = this.parent.transform.degree - obj.shapeDegree;
4855
- }
4903
+ degree = (obj.shapeDegree === 0) ? this.parent.transform.degree : this.parent.transform.degree - obj.shapeDegree;
4856
4904
  if (degree < 0) {
4857
4905
  degree = 360 + degree;
4858
4906
  }
4859
4907
  if (obj.flipObjColl) {
4860
- for (var i = 0; i < obj.flipObjColl.length; i++) {
4908
+ for (var i = 0, iLen = obj.flipObjColl.length; i < iLen; i++) {
4861
4909
  if (obj.flipObjColl[i].toLowerCase() === 'horizontal') {
4862
4910
  isHorizontalflip = true;
4863
4911
  }
@@ -4868,42 +4916,34 @@ var Selection = /** @class */ (function () {
4868
4916
  }
4869
4917
  if (degree === 0 || degree === 360) {
4870
4918
  if (isVerticalflip) {
4871
- rotationCirclePoint = { x: obj.topCenterCircle.startX,
4872
- y: obj.topCenterCircle.startY - obj.rotationCircleLine };
4919
+ rotationCirclePoint = { x: obj.topCenterCircle.startX, y: obj.topCenterCircle.startY - obj.rotationCircleLine };
4873
4920
  }
4874
4921
  else {
4875
- rotationCirclePoint = { x: obj.bottomCenterCircle.startX,
4876
- y: obj.bottomCenterCircle.startY + obj.rotationCircleLine };
4922
+ rotationCirclePoint = { x: obj.bottomCenterCircle.startX, y: obj.bottomCenterCircle.startY + obj.rotationCircleLine };
4877
4923
  }
4878
4924
  }
4879
4925
  else if (degree === 90 || degree === -270) {
4880
4926
  if (isHorizontalflip) {
4881
- rotationCirclePoint = { x: obj.centerRightCircle.startX +
4882
- obj.rotationCircleLine, y: obj.centerLeftCircle.startY };
4927
+ rotationCirclePoint = { x: obj.centerRightCircle.startX + obj.rotationCircleLine, y: obj.centerLeftCircle.startY };
4883
4928
  }
4884
4929
  else {
4885
- rotationCirclePoint = { x: obj.centerLeftCircle.startX -
4886
- obj.rotationCircleLine, y: obj.centerLeftCircle.startY };
4930
+ rotationCirclePoint = { x: obj.centerLeftCircle.startX - obj.rotationCircleLine, y: obj.centerLeftCircle.startY };
4887
4931
  }
4888
4932
  }
4889
4933
  else if (degree === 180 || degree === -180) {
4890
4934
  if (isVerticalflip) {
4891
- rotationCirclePoint = { x: obj.bottomCenterCircle.startX,
4892
- y: obj.bottomCenterCircle.startY + obj.rotationCircleLine };
4935
+ rotationCirclePoint = { x: obj.bottomCenterCircle.startX, y: obj.bottomCenterCircle.startY + obj.rotationCircleLine };
4893
4936
  }
4894
4937
  else {
4895
- rotationCirclePoint = { x: obj.topCenterCircle.startX,
4896
- y: obj.topCenterCircle.startY - obj.rotationCircleLine };
4938
+ rotationCirclePoint = { x: obj.topCenterCircle.startX, y: obj.topCenterCircle.startY - obj.rotationCircleLine };
4897
4939
  }
4898
4940
  }
4899
4941
  else if (degree === 270 || degree === -90) {
4900
4942
  if (isHorizontalflip) {
4901
- rotationCirclePoint = { x: obj.centerLeftCircle.startX -
4902
- obj.rotationCircleLine, y: obj.centerLeftCircle.startY };
4943
+ rotationCirclePoint = { x: obj.centerLeftCircle.startX - obj.rotationCircleLine, y: obj.centerLeftCircle.startY };
4903
4944
  }
4904
4945
  else {
4905
- rotationCirclePoint = { x: obj.centerRightCircle.startX +
4906
- obj.rotationCircleLine, y: obj.centerLeftCircle.startY };
4946
+ rotationCirclePoint = { x: obj.centerRightCircle.startX + obj.rotationCircleLine, y: obj.centerLeftCircle.startY };
4907
4947
  }
4908
4948
  }
4909
4949
  if (object) {
@@ -4912,17 +4952,19 @@ var Selection = /** @class */ (function () {
4912
4952
  return rotationCirclePoint;
4913
4953
  };
4914
4954
  Selection.prototype.getNumTextValue = function (obj) {
4955
+ var parent = this.parent;
4956
+ var elem = parent.element;
4915
4957
  var height;
4916
4958
  var width;
4917
4959
  var widthElement;
4918
4960
  var heightElement;
4919
- if (!isBlazor()) {
4920
- widthElement = this.parent.element.querySelector('#' + this.parent.element.id + '_resizeWidth');
4921
- heightElement = this.parent.element.querySelector('#' + this.parent.element.id + '_resizeHeight');
4961
+ if (isBlazor()) {
4962
+ widthElement = elem.querySelector('.e-ie-toolbar-e-resize-width-input .e-textbox');
4963
+ heightElement = elem.querySelector('.e-ie-toolbar-e-resize-height-input .e-textbox');
4922
4964
  }
4923
4965
  else {
4924
- widthElement = this.parent.element.querySelector('.e-ie-toolbar-e-resize-width-input .e-numerictextbox');
4925
- heightElement = this.parent.element.querySelector('.e-ie-toolbar-e-resize-height-input .e-numerictextbox');
4966
+ widthElement = elem.querySelector('#' + elem.id + '_resizeWidth');
4967
+ heightElement = elem.querySelector('#' + elem.id + '_resizeHeight');
4926
4968
  }
4927
4969
  if (widthElement && heightElement) {
4928
4970
  var heightString = heightElement.value.replace(/,/g, '');
@@ -4951,8 +4993,8 @@ var Selection = /** @class */ (function () {
4951
4993
  heightElement = this.parent.element.querySelector('#' + this.parent.element.id + '_resizeHeight');
4952
4994
  }
4953
4995
  else {
4954
- widthElement = this.parent.element.querySelector('.e-ie-toolbar-e-resize-width-input .e-numerictextbox');
4955
- heightElement = this.parent.element.querySelector('.e-ie-toolbar-e-resize-height-input .e-numerictextbox');
4996
+ widthElement = this.parent.element.querySelector('.e-ie-toolbar-e-resize-width-input .e-textbox');
4997
+ heightElement = this.parent.element.querySelector('.e-ie-toolbar-e-resize-height-input .e-textbox');
4956
4998
  }
4957
4999
  if (widthElement && heightElement) {
4958
5000
  if (heightElement.value.replace(/,/g, '') === '' && widthElement.value.replace(/,/g, '') === '') {