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

Add center_to_screen option to be used with limit_to_screen #261

Closed sconix closed 7 years ago

sconix commented 7 years ago

This adds new center_to_screen configuration option which will center the grid to the screen when using limit_to_screen. This is done by calculating screenMargin which is used in calculating the position for the placeholder / items.

BTMorton commented 7 years ago

I'm going to have to try this to get an idea of what the change does, if that's OK? I think I get it but I'd like to see it for myself first. What col_width/row_height values are you using?

sconix commented 7 years ago

So what this does is that we have the grid set to fill the available space and col_width / row_height are set to 162/136 with margin being 16. And we are using the limit_to_screen so the grid width naturally is not always evenly dividable with the 162+margin so without this feature the grid items would only be centered to the view when the grid width is evenly dividable with 162+margin. With this feature the grid is always center when center_to_screen is set to true.

sconix commented 7 years ago

I pushed the change with the refactoring for the re-positioning of the items. This was my original implementation anyway, but decided to go with the less code replication in the end.

BTMorton commented 7 years ago

I made a couple little changes, but it's in master now. Thanks 👍

sconix commented 7 years ago

Thanks! Also thanks for this nice library, we tried pretty much all grid related libraries and all others were really buggy and most of them tried to do too much like provide scrolling etc.

sconix commented 7 years ago

Hi, would it be possible for you to make new release with this feature? Since I see that there still hasn't been new release after adding this and we are getting close to releasing our app so would be nice to have only released package versions in the app when we ship it. The feature has been working nicely for us, been using it through our own custom build.

BTMorton commented 7 years ago

Yes! Apologies, I'll try to get it out this weekend

BTMorton commented 7 years ago

Released in version 2.1.0