BTMorton / angular2-grid

A drag/drop/resize grid-based plugin directive for angular2
https://bmorton.co.uk/angular/
MIT License
354 stars 159 forks source link

Support maxCol / maxRow simulatenously #250

Closed jpsfs closed 7 years ago

jpsfs commented 7 years ago

Hi!

Is there a reason why max_cols and max_rows are not supported simultaneously? I was hoping to achieve a similar result to:

image

Best,

BTMorton commented 7 years ago

Yes. By applying both max cols and max rows, it would then require lots of extra logic to figure out whether an item can still fit in the grid when it is added. The same result can be achieved by using max_cols and visible_rows which applies the same resizing logic, without adding any limitations to the number of items in the grid.

jpsfs commented 7 years ago

Hi @BTMorton,

Thanks for the reply! I see you point.

We have tried to use visible_rows but it seems that the calculation is being done take the window as basis and in our case the grid doesn't occupy the entire screen (as it happens on your own example). Would you accept a PR where we would use elementRef.nativeElement instead of window?

Best, José

BTMorton commented 7 years ago

Yes, I can't see there being too much issue with that

BTMorton commented 7 years ago

OK, I have added a new config property element_based_row_height which allows you to enable using the native element to calculate the visible row. It also no longer overrides the height with the max row as it assumes you are setting that yourself. Apologies this took so long to get to.