gridstack.js icon indicating copy to clipboard operation
gridstack.js copied to clipboard

Empty grid default height

Open Myrdivar opened this issue 10 years ago • 7 comments

Hi,

Is there an option to set the minHeight for the grid? In this way for example, when it's empty, I'll still be able to drop element on it.

Even in your dual grid example (http://troolee.github.io/gridstack.js/demo/two.html) if I move all elements from the left grid to the right one I'll not be able to drop elements on the left grid anymore.

Myrdivar avatar Aug 19 '16 08:08 Myrdivar

I mean, you could always set "min-height" to the grid element but maybe an option in the component could be useful :)

Myrdivar avatar Aug 19 '16 08:08 Myrdivar

Hi, you can setup min height for the grid in css:

.grid-stack { min-height: 300px; }

troolee avatar Aug 19 '16 20:08 troolee

Setting the min-height for the grid seems to screw up the drag position calculations. For example, items have to be dragged further down before the item changes position. Is there a way to set min--height on the grid without this happening?

kurigohan avatar Aug 31 '16 18:08 kurigohan

@troolee Setting min-height does seem to make the resizing of elements act weird as @kurigohan mentioned. (As a workaround I’m adding a ‘ghost’ element to the grid if it is empty).

barryceelen avatar Sep 28 '16 11:09 barryceelen

Why is this issue closed? setting min-height via css broke grid usage and there is no option for min height

iveretelnyk avatar May 05 '17 23:05 iveretelnyk

+1 - It would be nice if the grid can be instantiated without elements. I use the gridstack.js for creating a form. The user can drop new elements into the canvas.

I am using the draggable event of the elements outside the grid to add a min-height to the .grid-stack class on drag-start. On stop, I remove the class to not break the grid itself.

abayob avatar May 10 '17 09:05 abayob

+1 @barryceelen for his workaround. I used a "ghost" element as suggested have this this issue solved. I set it height to the maximum height of the grid element then I set the content backgroud-color to be transparent, no moved and locked then I push it to the right left. Code of my ghost element <div class="grid-stack-item" data-gs-locked="true" data-gs-x="12" data-gs-y="0" data-gs-no-move="true" data-gs-width="1" data-gs-height="6"> <div class="grid-stack-item-content" style="background-color: transparent;"></div> </div>

Doopin avatar Jul 06 '18 20:07 Doopin