File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
packages/element-selection/src Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -409,9 +409,9 @@ export default class CropperSelection extends CropperElement {
409
409
return ;
410
410
}
411
411
412
- const moveX = detail . endX - detail . startX ;
413
- const moveY = detail . endY - detail . startY ;
414
412
const { width, height } = this ;
413
+ let moveX = detail . endX - detail . startX ;
414
+ let moveY = detail . endY - detail . startY ;
415
415
let { aspectRatio } = this ;
416
416
417
417
// Locking aspect ratio by holding shift key
@@ -421,7 +421,14 @@ export default class CropperSelection extends CropperElement {
421
421
422
422
switch ( action ) {
423
423
case ACTION_SELECT :
424
- if ( moveX !== 0 && moveY !== 0 ) {
424
+ if ( moveX !== 0 || moveY !== 0 ) {
425
+ // Force to create a square selection for better user experience
426
+ if ( moveX === 0 ) {
427
+ moveX = moveY ;
428
+ } else if ( moveY === 0 ) {
429
+ moveY = moveX ;
430
+ }
431
+
425
432
const { $canvas } = this ;
426
433
const offset = getOffset ( currentTarget as Element ) ;
427
434
You can’t perform that action at this time.
0 commit comments