@@ -447,28 +447,56 @@ export class Rnd extends React.PureComponent<Props, State> {
447447 const hasTop = dir . startsWith ( "top" ) ;
448448 const hasBottom = dir . startsWith ( "bottom" ) ;
449449
450- if ( ( hasLeft || hasTop ) && this . resizable ) {
451- const max = ( selfLeft - boundaryLeft ) / scale + this . resizable . size . width ;
452- this . setState ( { maxWidth : max > Number ( maxWidth ) ? maxWidth : max } ) ;
453- }
454- // INFO: To set bounds in `lock aspect ratio with bounds` case. See also that story.
455- if ( hasRight || ( this . props . lockAspectRatio && ! hasLeft && ! hasTop ) ) {
456- const max = offsetWidth + ( boundaryLeft - selfLeft ) / scale ;
457- this . setState ( { maxWidth : max > Number ( maxWidth ) ? maxWidth : max } ) ;
458- }
459- if ( ( hasTop || hasLeft ) && this . resizable ) {
460- const max = ( selfTop - boundaryTop ) / scale + this . resizable . size . height ;
461- this . setState ( {
462- maxHeight : max > Number ( maxHeight ) ? maxHeight : max ,
463- } ) ;
464- }
465- // INFO: To set bounds in `lock aspect ratio with bounds` case. See also that story.
466- if ( hasBottom || ( this . props . lockAspectRatio && ! hasTop && ! hasLeft ) ) {
467- const max = offsetHeight + ( boundaryTop - selfTop ) / scale ;
468- this . setState ( {
469- maxHeight : max > Number ( maxHeight ) ? maxHeight : max ,
470- } ) ;
450+ if ( ! this . props . resizeSymmetry || this . props . resizeSymmetry == "none" )
451+ {
452+ if ( ( hasLeft || hasTop ) && this . resizable ) {
453+ const max = ( selfLeft - boundaryLeft ) / scale + this . resizable . size . width ;
454+ this . setState ( { maxWidth : max > Number ( maxWidth ) ? maxWidth : max } ) ;
455+ }
456+ // INFO: To set bounds in `lock aspect ratio with bounds` case. See also that story.
457+ if ( hasRight || ( this . props . lockAspectRatio && ! hasLeft && ! hasTop ) ) {
458+ const max = offsetWidth + ( boundaryLeft - selfLeft ) / scale ;
459+ this . setState ( { maxWidth : max > Number ( maxWidth ) ? maxWidth : max } ) ;
460+ }
461+ if ( ( hasTop || hasLeft ) && this . resizable ) {
462+ const max = ( selfTop - boundaryTop ) / scale + this . resizable . size . height ;
463+ this . setState ( {
464+ maxHeight : max > Number ( maxHeight ) ? maxHeight : max ,
465+ } ) ;
466+ }
467+ // INFO: To set bounds in `lock aspect ratio with bounds` case. See also that story.
468+ if ( hasBottom || ( this . props . lockAspectRatio && ! hasTop && ! hasLeft ) ) {
469+ const max = offsetHeight + ( boundaryTop - selfTop ) / scale ;
470+ this . setState ( {
471+ maxHeight : max > Number ( maxHeight ) ? maxHeight : max ,
472+ } ) ;
473+ }
471474 }
475+ else
476+ {
477+ if ( ( hasLeft || hasTop || hasRight || ( this . props . lockAspectRatio && ! hasLeft && ! hasTop ) ) && this . resizable ) {
478+ if ( this . props . resizeSymmetry == "vertical" || this . props . resizeSymmetry == "central" )
479+ {
480+ const spaceLeft = ( selfLeft - boundaryLeft ) / scale ;
481+ const spaceRight = offsetWidth - spaceLeft - this . resizable . size . width ;
482+ const max = spaceRight > spaceLeft ? ( this . resizable . size . width + 2 * spaceLeft ) : ( this . resizable . size . width + 2 * spaceRight ) ;
483+ this . setState ( { maxWidth : max > Number ( maxWidth ) ? maxWidth : max } ) ;
484+ }
485+ }
486+
487+ if ( ( hasTop || hasLeft || hasBottom || ( this . props . lockAspectRatio && ! hasTop && ! hasLeft ) ) && this . resizable ) {
488+ if ( this . props . resizeSymmetry == "horizontal" || this . props . resizeSymmetry == "central" )
489+ {
490+ const spaceTop = ( selfTop - boundaryTop ) / scale ;
491+ const spaceBottom = offsetHeight - spaceTop - this . resizable . size . height ;
492+ const max = spaceBottom > spaceTop ? ( this . resizable . size . height + 2 * spaceTop ) : ( this . resizable . size . height + 2 * spaceBottom ) ;
493+
494+ this . setState ( {
495+ maxHeight : max > Number ( maxHeight ) ? maxHeight : max ,
496+ } ) ;
497+ }
498+ }
499+ }
472500 }
473501 } else {
474502 this . setState ( {
@@ -505,7 +533,7 @@ export class Rnd extends React.PureComponent<Props, State> {
505533 }
506534 }
507535 }
508- else if ( ! this . props . resizeSymmetry || this . props . resizeSymmetry == "vertical" )
536+ else if ( this . props . resizeSymmetry == "vertical" )
509537 {
510538 const left = - delta . width / 2 ;
511539 const top = - delta . height ;
@@ -522,7 +550,7 @@ export class Rnd extends React.PureComponent<Props, State> {
522550 }
523551 }
524552 }
525- else if ( ! this . props . resizeSymmetry || this . props . resizeSymmetry == "horizontal" )
553+ else if ( this . props . resizeSymmetry == "horizontal" )
526554 {
527555 const left = - delta . width ;
528556 const top = - delta . height / 2 ;
@@ -536,7 +564,7 @@ export class Rnd extends React.PureComponent<Props, State> {
536564 }
537565 }
538566 }
539- else if ( ! this . props . resizeSymmetry || this . props . resizeSymmetry == "central" )
567+ else if ( this . props . resizeSymmetry == "central" )
540568 {
541569 const left = - delta . width / 2 ;
542570 const top = - delta . height / 2 ;
0 commit comments