getCellFromPixel fails when data-gs-current-height is zero
I have migrated from version 0.23 to 0.30 and the getCellFromPixel function is failing for me.
On my scenario the grid stack container is initialized like this:
this.$el.gridstack({ cellHeight: 20, width: 24, verticalMargin: 10 });
The initial state of the gridstack container has height = 0.
I use gridstack to let the users create custom forms on which they can drag and drop controls into the gridstack. When they drop a form control, a function is executed to generate the item in the gridstack. This function calls getCellFromPixel to calculate the position.
The following line of the getCellFromPixel function is failing for me because the initial state of data-gs-current-height is zero
var rowHeight = Math.floor(this.container.height() / parseInt(this.container.attr('data-gs-current-height')));
The line in version 0.23 was:
var row_height = this.opts.cell_height + this.opts.vertical_margin;
... and this was working fine becase the values were taken from my gridstack options.
@lopezcjf Could you put together a jsfiddle? Also, what was your previous value in 0.23?
I just want to note that if the height is 0, this probably should not work. If the height is 1, wouldn't this work fine?
Closing due to inactivity. Please reopen if there's still an issue.
Hello @radiolips : can you please reopen this. I am using Ngx-gridstack where users can drag and drop the widgets from one div to another. After dropping the widget, we can use the mouse co-ordinates to calculate the cell positions. But the problem is data-gs-current-height is set to 1 and because of this, no matter where i drop the widgets, it ends up showing in the first row. Can you please let me know how to update 'data-gs-current-height'