Is it possible to create vertically responsive/scaling grids and widgets
Hi.
It's easy enough to create a horizontally responsive grid with 100% width and this does seem to behave quite nicely.
Is there a similar way to set the grid to 100% of the viewport height while each widget inside also scales vertically to fit? The idea is that, exactly in the same manner as the grid scales horizontally, the grid will also scale vertically.
Thanks, Jarl
You could probably use a variant of this trick:
https://github.com/troolee/gridstack.js/issues/102#issuecomment-133538587
But I think you'd have to set cell height programmatically on window resize events.
Thanks. I'll try to implement the current horizontal bootstrap scaling scheme in a similar vertical fashion where there are 12 rows which stretch to adapt to the height of the viewport. Plenty nice tips to try in the Stack Overflow linked in #102. I'll try with vh and vw units for fun too.
The task in brief seems to be:
- [ ] CSS: Create additional classes to accomodate for % height in place of px height
.grid-stack-item[data-gs-height="2"] {
height: 140px; ---> height: 16.6666%;
}
This will allow vertical sizing according to
- [ ] JavaScript: Create alternative %-height aware implementation of the following:
Options:
height,cell_height,vertical_marginGrid attributes:data-gs-animate,data-gs-heightItem attributes:data-gs-y,data-gs-height,data-gs-max-height,data-gs-min-height - [ ] API: I guess part of the API also might some kind of update. This might at least apply to the following functions:
add_widget(el, x, y, width, height, auto_position)cell_height()cell_height(val)get_cell_from_pixel(position)is_area_empty(x, y, width, height)min_height(el, val)move(el, x, y)resize(el, width, height)update(el, x, y, width, height)will_it_fit(x, y, width, height, auto_position)
@jarlarntzen Hey, were you able to solve vertical aligning issue?
I solved this issue changing the line 522 in gridstack.js to :
'height: ' + ((this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i))/7.7 + '%;',
and changing the 537 line in gridstack.js to :
'top: ' + ((this.opts.cell_height * i + this.opts.vertical_margin * i))/7.7 + '%;',
and in your own CSS line give
.gridstack{
height: 100% !important;
}
Looks very cool! I have to get around to try this! Thanks!
On Fri, Jan 8, 2016 at 8:15 PM, Harshal [email protected] wrote:
I solved this issue changing the line 522 in gridstack.js to :
'height: ' + ((this.opts.cell_height * (i + 1) + this.opts.vertical_margin
- i))/7.7 + '%;',
and changing the 537 line in gridstack.js to :
'top: ' + ((this.opts.cell_height * i + this.opts.vertical_margin * i))/7.7 + '%;',
and in your own CSS line give
.gridstack{ height: 100% !important; }
— Reply to this email directly or view it on GitHub https://github.com/troolee/gridstack.js/issues/250#issuecomment-170097030 .
Scaling can be done, as @McQuinTrix has mentioned, by modifying CSS and by tapping into the JS (modifying gridstack.js is not preferred, but this can be done by listening to events instead). Closing this ticket. Please let me know if you have further issue.
Thanks to everyone for the tips. Since I couldn't find a full working solution anywhere, I thought I would provide a link to this example that does not involve modifying gridstack.js.