@@ -207,15 +207,9 @@ export class GridStack {
207207 /** scoping so users can call new GridStack.Engine(12) for example */
208208 public static Engine = GridStackEngine ;
209209
210- /** the HTML element tied to this grid after it's been initialized */
211- public el : GridHTMLElement ;
212-
213210 /** engine used to implement non DOM grid functionality */
214211 public engine : GridStackEngine ;
215212
216- /** grid options - public for classes to access, but use methods to modify! */
217- public opts : GridStackOptions ;
218-
219213 /** point to a parent grid item if we're nested (inside a grid-item in between 2 Grids) */
220214 public parentGridItem ?: GridStackNode ;
221215
@@ -267,12 +261,11 @@ export class GridStack {
267261
268262 /**
269263 * Construct a grid item from the given element and options
270- * @param el
271- * @param opts
264+ * @param el the HTML element tied to this grid after it's been initialized
265+ * @param opts grid options - public for classes to access, but use methods to modify!
272266 */
273- public constructor ( el : GridHTMLElement , opts : GridStackOptions = { } ) {
267+ public constructor ( public el : GridHTMLElement , public opts : GridStackOptions = { } ) {
274268 el . gridstack = this ;
275- this . el = el ; // exposed HTML element to the user
276269 opts = opts || { } ; // handles null/undefined/0
277270
278271 if ( ! el . classList . contains ( 'grid-stack' ) ) {
@@ -344,18 +337,17 @@ export class GridStack {
344337 defaults . animate = Utils . toBool ( el . getAttribute ( 'gs-animate' ) )
345338 }
346339
347- this . opts = Utils . defaults ( opts , defaults ) ;
348- opts = null ; // make sure we use this.opts instead
340+ opts = Utils . defaults ( opts , defaults ) ;
349341 this . _initMargin ( ) ; // part of settings defaults...
350342
351343 // Now check if we're loading into 1 column mode FIRST so we don't do un-necessary work (like cellHeight = width / 12 then go 1 column)
352344 this . checkDynamicColumn ( ) ;
353- this . el . classList . add ( 'gs-' + this . opts . column ) ;
345+ this . el . classList . add ( 'gs-' + opts . column ) ;
354346
355- if ( this . opts . rtl === 'auto' ) {
356- this . opts . rtl = ( el . style . direction === 'rtl' ) ;
347+ if ( opts . rtl === 'auto' ) {
348+ opts . rtl = ( el . style . direction === 'rtl' ) ;
357349 }
358- if ( this . opts . rtl ) {
350+ if ( opts . rtl ) {
359351 this . el . classList . add ( 'grid-stack-rtl' ) ;
360352 }
361353
@@ -369,34 +361,34 @@ export class GridStack {
369361 parentGridItem . el . classList . add ( 'grid-stack-sub-grid' ) ;
370362 }
371363
372- this . _isAutoCellHeight = ( this . opts . cellHeight === 'auto' ) ;
373- if ( this . _isAutoCellHeight || this . opts . cellHeight === 'initial' ) {
364+ this . _isAutoCellHeight = ( opts . cellHeight === 'auto' ) ;
365+ if ( this . _isAutoCellHeight || opts . cellHeight === 'initial' ) {
374366 // make the cell content square initially (will use resize/column event to keep it square)
375367 this . cellHeight ( undefined , false ) ;
376368 } else {
377369 // append unit if any are set
378- if ( typeof this . opts . cellHeight == 'number' && this . opts . cellHeightUnit && this . opts . cellHeightUnit !== gridDefaults . cellHeightUnit ) {
379- this . opts . cellHeight = this . opts . cellHeight + this . opts . cellHeightUnit ;
380- delete this . opts . cellHeightUnit ;
370+ if ( typeof opts . cellHeight == 'number' && opts . cellHeightUnit && opts . cellHeightUnit !== gridDefaults . cellHeightUnit ) {
371+ opts . cellHeight = opts . cellHeight + opts . cellHeightUnit ;
372+ delete opts . cellHeightUnit ;
381373 }
382- this . cellHeight ( this . opts . cellHeight , false ) ;
374+ this . cellHeight ( opts . cellHeight , false ) ;
383375 }
384376
385377 // see if we need to adjust auto-hide
386- if ( this . opts . alwaysShowResizeHandle === 'mobile' ) {
387- this . opts . alwaysShowResizeHandle = isTouch ;
378+ if ( opts . alwaysShowResizeHandle === 'mobile' ) {
379+ opts . alwaysShowResizeHandle = isTouch ;
388380 }
389381
390382 this . _styleSheetClass = 'gs-id-' + GridStackEngine . _idSeq ++ ;
391383 this . el . classList . add ( this . _styleSheetClass ) ;
392384
393385 this . _setStaticClass ( ) ;
394386
395- let engineClass = this . opts . engineClass || GridStack . engineClass || GridStackEngine ;
387+ let engineClass = opts . engineClass || GridStack . engineClass || GridStackEngine ;
396388 this . engine = new engineClass ( {
397389 column : this . getColumn ( ) ,
398- float : this . opts . float ,
399- maxRow : this . opts . maxRow ,
390+ float : opts . float ,
391+ maxRow : opts . maxRow ,
400392 onChange : ( cbNodes ) => {
401393 let maxH = 0 ;
402394 this . engine . nodes . forEach ( n => { maxH = Math . max ( maxH , n . y + n . h ) } ) ;
@@ -417,25 +409,25 @@ export class GridStack {
417409 // create initial global styles BEFORE loading children so resizeToContent margin can be calculated correctly
418410 this . _updateStyles ( false , 0 ) ;
419411
420- if ( this . opts . auto ) {
412+ if ( opts . auto ) {
421413 this . batchUpdate ( ) ; // prevent in between re-layout #1535 TODO: this only set float=true, need to prevent collision check...
422414 this . getGridItems ( ) . forEach ( el => this . _prepareElement ( el ) ) ;
423415 this . batchUpdate ( false ) ;
424416 }
425417
426418 // load any passed in children as well, which overrides any DOM layout done above
427- if ( this . opts . children ) {
428- let children = this . opts . children ;
429- delete this . opts . children ;
419+ if ( opts . children ) {
420+ let children = opts . children ;
421+ delete opts . children ;
430422 if ( children . length ) this . load ( children ) ; // don't load empty
431423 }
432424
433425 // if (this.engine.nodes.length) this._updateStyles(); // update based on # of children. done in engine onChange CB
434- this . setAnimation ( this . opts . animate ) ;
426+ this . setAnimation ( opts . animate ) ;
435427
436428 // dynamic grids require pausing during drag to detect over to nest vs push
437- if ( this . opts . subGridDynamic && ! DDManager . pauseDrag ) DDManager . pauseDrag = true ;
438- if ( this . opts . draggable ?. pause !== undefined ) DDManager . pauseDrag = this . opts . draggable . pause ;
429+ if ( opts . subGridDynamic && ! DDManager . pauseDrag ) DDManager . pauseDrag = true ;
430+ if ( opts . draggable ?. pause !== undefined ) DDManager . pauseDrag = opts . draggable . pause ;
439431
440432 this . _setupRemoveDrop ( ) ;
441433 this . _setupAcceptWidget ( ) ;
0 commit comments