446
446
var css ;
447
447
css = '.' + this . opts . _class + ' .' + this . opts . item_class + '[data-gs-height="' + ( i + 1 ) + '"] { height: ' + ( this . opts . cell_height * ( i + 1 ) + this . opts . vertical_margin * i ) + 'px; }' ;
448
448
this . _styles . insertRule ( css , i ) ;
449
+ css = '.' + this . opts . _class + ' .' + this . opts . item_class + '[data-gs-min-height="' + ( i + 1 ) + '"] { min-height: ' + ( this . opts . cell_height * ( i + 1 ) + this . opts . vertical_margin * i ) + 'px; }' ;
450
+ this . _styles . insertRule ( css , i ) ;
451
+ css = '.' + this . opts . _class + ' .' + this . opts . item_class + '[data-gs-max-height="' + ( i + 1 ) + '"] { max-height: ' + ( this . opts . cell_height * ( i + 1 ) + this . opts . vertical_margin * i ) + 'px; }' ;
452
+ this . _styles . insertRule ( css , i ) ;
449
453
css = '.' + this . opts . _class + ' .' + this . opts . item_class + '[data-gs-y="' + ( i ) + '"] { top: ' + ( this . opts . cell_height * i + this . opts . vertical_margin * i ) + 'px; }' ;
450
454
this . _styles . insertRule ( css , i ) ;
451
455
}
582
586
this . container . append ( el ) ;
583
587
this . _prepare_element ( el ) ;
584
588
this . _update_container_height ( ) ;
589
+
590
+ return el ;
585
591
} ;
586
592
587
593
GridStack . prototype . will_it_fit = function ( x , y , width , height , auto_position ) {
724
730
return Math . ceil ( o . outerWidth ( ) / o . attr ( 'data-gs-width' ) ) ;
725
731
} ;
726
732
733
+ GridStack . prototype . get_cell_from_pixel = function ( position ) {
734
+ var containerPos = this . container . position ( ) ;
735
+ var relativeLeft = position . left - containerPos . left ;
736
+ var relativeTop = position . top - containerPos . top ;
737
+
738
+ var column_width = Math . floor ( this . container . width ( ) / this . opts . width ) ;
739
+ var row_height = this . opts . cell_height + this . opts . vertical_margin ;
740
+
741
+ return { x : Math . floor ( relativeLeft / column_width ) , y : Math . floor ( relativeTop / row_height ) } ;
742
+ } ;
743
+
727
744
scope . GridStackUI = GridStack ;
728
745
729
746
scope . GridStackUI . Utils = Utils ;
737
754
} ;
738
755
739
756
return scope . GridStackUI ;
740
- } ) ;
757
+ } ) ;
0 commit comments