@@ -16,7 +16,9 @@ export interface DDResizableOpt {
16
16
autoHide ?: boolean ;
17
17
handles ?: string ;
18
18
maxHeight ?: number ;
19
+ maxHeightMoveUp ?: number ;
19
20
maxWidth ?: number ;
21
+ maxWidthMoveLeft ?: number ;
20
22
minHeight ?: number ;
21
23
minWidth ?: number ;
22
24
start ?: ( event : Event , ui : DDUIData ) => void ;
@@ -254,20 +256,24 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
254
256
255
257
const offsetX = event . clientX - oEvent . clientX ;
256
258
const offsetY = this . sizeToContent ? 0 : event . clientY - oEvent . clientY ; // prevent vert resize
259
+ let moveLeft : boolean ;
260
+ let moveUp : boolean ;
257
261
258
262
if ( dir . indexOf ( 'e' ) > - 1 ) {
259
263
newRect . width += offsetX ;
260
264
} else if ( dir . indexOf ( 'w' ) > - 1 ) {
261
265
newRect . width -= offsetX ;
262
266
newRect . left += offsetX ;
267
+ moveLeft = true ;
263
268
}
264
269
if ( dir . indexOf ( 's' ) > - 1 ) {
265
270
newRect . height += offsetY ;
266
271
} else if ( dir . indexOf ( 'n' ) > - 1 ) {
267
272
newRect . height -= offsetY ;
268
273
newRect . top += offsetY
274
+ moveUp = true ;
269
275
}
270
- const constrain = this . _constrainSize ( newRect . width , newRect . height ) ;
276
+ const constrain = this . _constrainSize ( newRect . width , newRect . height , moveLeft , moveUp ) ;
271
277
if ( Math . round ( newRect . width ) !== Math . round ( constrain . width ) ) { // round to ignore slight round-off errors
272
278
if ( dir . indexOf ( 'w' ) > - 1 ) {
273
279
newRect . left += newRect . width - constrain . width ;
@@ -284,11 +290,12 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
284
290
}
285
291
286
292
/** @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 ;
292
299
const width = Math . min ( maxWidth , Math . max ( minWidth , oWidth ) ) ;
293
300
const height = Math . min ( maxHeight , Math . max ( minHeight , oHeight ) ) ;
294
301
return { width, height } ;
0 commit comments