Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose current grid dimension #298

Closed
macftw opened this issue Apr 9, 2018 · 5 comments
Closed

Expose current grid dimension #298

macftw opened this issue Apr 9, 2018 · 5 comments
Milestone

Comments

@macftw
Copy link

macftw commented Apr 9, 2018

Is it possible to expose the current with and height of the grid as reflected in the .gridster-column elements? Preferably by an event that fires whenever the grid dimension changes (during drag, deletion, insertion, etc.).

I am currently trying a workaround by watching the gridster-column element with an MutationObserver which seems like a hacky solution (and also doesn't work as expected).

I also tried to check the dimension onDragStop which doesn't quite work either since it fires immediately while the grid is still animating.

I'm thinking of a gridSizeChanged callback in the options which fires whenever rows or columns are added/removed. Or is this already possible and I'm missing something?
Thank you for your help!

@tiberiuzuld
Copy link
Owner

tiberiuzuld commented Apr 9, 2018

Hi @macftw ,
Currently you can see the grid cols and rows by using the initCallback and get the gridsterComponent.

You can use the callbacks itemInitCallback, itemRemovedCallback, and itemChangeCallback and read again the cols,rows.

If you want to obtain something to set the height/width of the grid some like this #292
Will cover it in that issue.

If not will add a gridSizeChanged callback.

Thanks

@macftw
Copy link
Author

macftw commented Apr 10, 2018

Thank you @tiberiuzuld for the quick reply.
I already tried using the existing callbacks but they don't provide a callback when the grid size changes during dragging.

Also the itemRemovedCallback immediately fires while the grid is still shrinking, so I can't read the correct grid size there.

I think a gridSizeChanged callback would be useful.

@tiberiuzuld
Copy link
Owner

Ok will add a gridSizeChangedCallback as soon as possible.

@tiberiuzuld
Copy link
Owner

Added in v5.3.0

@tiberiuzuld tiberiuzuld added this to the 5.x milestone Apr 21, 2018
@viethien
Copy link

viethien commented Jul 9, 2019

Hello @tiberiuzuld

I tried to use gridSizeChangedCallback, but it has never fired.
this.options = {
gridType: this.gridType,
enableEmptyCellDrop: true,
emptyCellDropCallback: this.onDrop.bind(this),
gridSizeChangedCallback: this.gridSizeChanged.bind(this),

...
}

How can I trigged gridSizeChangedCallback when grid size change in this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants