6
6
import { DDResizableHandle } from './dd-resizable-handle' ;
7
7
import { DDBaseImplement , HTMLElementExtendOpt } from './dd-base-impl' ;
8
8
import { Utils } from './utils' ;
9
- import { DDUIData , Rect , Size } from './types' ;
9
+ import { DDUIData , GridItemHTMLElement , Rect , Size } from './types' ;
10
10
import { DDManager } from './dd-manager' ;
11
11
12
12
// import { GridItemHTMLElement } from './types'; let count = 0; // TEST
@@ -32,7 +32,7 @@ interface RectScaleReciprocal {
32
32
export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt < DDResizableOpt > {
33
33
34
34
// have to be public else complains for HTMLElementExtendOpt ?
35
- public el : HTMLElement ;
35
+ public el : GridItemHTMLElement ;
36
36
public option : DDResizableOpt ;
37
37
38
38
/** @internal */
@@ -57,6 +57,8 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
57
57
protected parentOriginStylePosition : string ;
58
58
/** @internal */
59
59
protected static _originStyleProp = [ 'width' , 'height' , 'position' , 'left' , 'top' , 'opacity' , 'zIndex' ] ;
60
+ /** @internal */
61
+ protected sizeToContent : boolean ;
60
62
61
63
constructor ( el : HTMLElement , opts : DDResizableOpt = { } ) {
62
64
super ( ) ;
@@ -152,11 +154,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
152
154
153
155
/** @internal */
154
156
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 ( ',' )
160
158
. map ( dir => dir . trim ( ) )
161
159
. map ( dir => new DDResizableHandle ( this . el , dir , {
162
160
start : ( event : MouseEvent ) => {
@@ -174,6 +172,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
174
172
175
173
/** @internal */
176
174
protected _resizeStart ( event : MouseEvent ) : DDResizable {
175
+ this . sizeToContent = Utils . shouldSizeToContent ( this . el . gridstackNode ) ;
177
176
this . originalRect = this . el . getBoundingClientRect ( ) ;
178
177
this . scrollEl = Utils . getScrollElement ( this . el ) ;
179
178
this . scrollY = this . scrollEl . scrollTop ;
@@ -260,7 +259,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
260
259
} ;
261
260
262
261
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
264
263
265
264
if ( dir . indexOf ( 'e' ) > - 1 ) {
266
265
newRect . width += offsetX ;
0 commit comments