@@ -16,7 +16,9 @@ export interface DDResizableOpt {
1616 autoHide ?: boolean ;
1717 handles ?: string ;
1818 maxHeight ?: number ;
19+ maxHeightMoveUp ?: number ;
1920 maxWidth ?: number ;
21+ maxWidthMoveLeft ?: number ;
2022 minHeight ?: number ;
2123 minWidth ?: number ;
2224 start ?: ( event : Event , ui : DDUIData ) => void ;
@@ -254,20 +256,24 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
254256
255257 const offsetX = event . clientX - oEvent . clientX ;
256258 const offsetY = this . sizeToContent ? 0 : event . clientY - oEvent . clientY ; // prevent vert resize
259+ let moveLeft : boolean ;
260+ let moveUp : boolean ;
257261
258262 if ( dir . indexOf ( 'e' ) > - 1 ) {
259263 newRect . width += offsetX ;
260264 } else if ( dir . indexOf ( 'w' ) > - 1 ) {
261265 newRect . width -= offsetX ;
262266 newRect . left += offsetX ;
267+ moveLeft = true ;
263268 }
264269 if ( dir . indexOf ( 's' ) > - 1 ) {
265270 newRect . height += offsetY ;
266271 } else if ( dir . indexOf ( 'n' ) > - 1 ) {
267272 newRect . height -= offsetY ;
268273 newRect . top += offsetY
274+ moveUp = true ;
269275 }
270- const constrain = this . _constrainSize ( newRect . width , newRect . height ) ;
276+ const constrain = this . _constrainSize ( newRect . width , newRect . height , moveLeft , moveUp ) ;
271277 if ( Math . round ( newRect . width ) !== Math . round ( constrain . width ) ) { // round to ignore slight round-off errors
272278 if ( dir . indexOf ( 'w' ) > - 1 ) {
273279 newRect . left += newRect . width - constrain . width ;
@@ -284,11 +290,12 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
284290 }
285291
286292 /** @internal constrain the size to the set min/max values */
287- protected _constrainSize ( oWidth : number , oHeight : number ) : Size {
288- const maxWidth = this . option . maxWidth || Number . MAX_SAFE_INTEGER ;
289- const minWidth = this . option . minWidth / this . rectScale . x || oWidth ;
290- const maxHeight = this . option . maxHeight || Number . MAX_SAFE_INTEGER ;
291- const minHeight = this . option . minHeight / this . rectScale . y || oHeight ;
293+ protected _constrainSize ( oWidth : number , oHeight : number , moveLeft : boolean , moveUp : boolean ) : Size {
294+ const o = this . option ;
295+ const maxWidth = ( moveLeft ? o . maxWidthMoveLeft : o . maxWidth ) || Number . MAX_SAFE_INTEGER ;
296+ const minWidth = o . minWidth / this . rectScale . x || oWidth ;
297+ const maxHeight = ( moveUp ? o . maxHeightMoveUp : o . maxHeight ) || Number . MAX_SAFE_INTEGER ;
298+ const minHeight = o . minHeight / this . rectScale . y || oHeight ;
292299 const width = Math . min ( maxWidth , Math . max ( minWidth , oWidth ) ) ;
293300 const height = Math . min ( maxHeight , Math . max ( minHeight , oHeight ) ) ;
294301 return { width, height } ;
0 commit comments