66import { DDResizableHandle } from './dd-resizable-handle' ;
77import { DDBaseImplement , HTMLElementExtendOpt } from './dd-base-impl' ;
88import { Utils } from './utils' ;
9- import { DDUIData , Rect , Size } from './types' ;
9+ import { DDUIData , GridItemHTMLElement , Rect , Size } from './types' ;
1010import { DDManager } from './dd-manager' ;
1111
1212// import { GridItemHTMLElement } from './types'; let count = 0; // TEST
@@ -32,7 +32,7 @@ interface RectScaleReciprocal {
3232export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt < DDResizableOpt > {
3333
3434 // have to be public else complains for HTMLElementExtendOpt ?
35- public el : HTMLElement ;
35+ public el : GridItemHTMLElement ;
3636 public option : DDResizableOpt ;
3737
3838 /** @internal */
@@ -57,6 +57,8 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
5757 protected parentOriginStylePosition : string ;
5858 /** @internal */
5959 protected static _originStyleProp = [ 'width' , 'height' , 'position' , 'left' , 'top' , 'opacity' , 'zIndex' ] ;
60+ /** @internal */
61+ protected sizeToContent : boolean ;
6062
6163 constructor ( el : HTMLElement , opts : DDResizableOpt = { } ) {
6264 super ( ) ;
@@ -152,11 +154,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
152154
153155 /** @internal */
154156 protected _setupHandlers ( ) : DDResizable {
155- let handlerDirection = this . option . handles || 'e,s,se' ;
156- if ( handlerDirection === 'all' ) {
157- handlerDirection = 'n,e,s,w,se,sw,ne,nw' ;
158- }
159- this . handlers = handlerDirection . split ( ',' )
157+ this . handlers = this . option . handles . split ( ',' )
160158 . map ( dir => dir . trim ( ) )
161159 . map ( dir => new DDResizableHandle ( this . el , dir , {
162160 start : ( event : MouseEvent ) => {
@@ -174,6 +172,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
174172
175173 /** @internal */
176174 protected _resizeStart ( event : MouseEvent ) : DDResizable {
175+ this . sizeToContent = Utils . shouldSizeToContent ( this . el . gridstackNode ) ;
177176 this . originalRect = this . el . getBoundingClientRect ( ) ;
178177 this . scrollEl = Utils . getScrollElement ( this . el ) ;
179178 this . scrollY = this . scrollEl . scrollTop ;
@@ -260,7 +259,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
260259 } ;
261260
262261 const offsetX = event . clientX - oEvent . clientX ;
263- const offsetY = event . clientY - oEvent . clientY ;
262+ const offsetY = this . sizeToContent ? 0 : event . clientY - oEvent . clientY ; // prevent vert resize
264263
265264 if ( dir . indexOf ( 'e' ) > - 1 ) {
266265 newRect . width += offsetX ;
0 commit comments