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

Return changed widgets instead of all widgets after a 'change' event #164

Closed
jffaust opened this issue Jun 10, 2015 · 7 comments
Closed

Comments

@jffaust
Copy link
Contributor

jffaust commented Jun 10, 2015

I'm talking about this : https://github.com/troolee/gridstack.js#onchangeitems

Why would we need the information about items that didn't change position or size ?

Wouldn't it be more practical to return the items that changed and not all of the items?

@troolee
Copy link
Member

troolee commented Jun 25, 2015

Hi,

Right now onchange event contains a list of items that were probably changed during the movement. I think I could change this in future and return only those items that were actually change their parameters.

@jffaust
Copy link
Contributor Author

jffaust commented Jun 25, 2015

Hello @troolee , what do you mean by 'probably changed' ?

I think it would be great to have only the items that their parameters changed. I checked the code a bit and I saw some code about nodes being dirty or something like that. What is the purpose of that ?

@troolee
Copy link
Member

troolee commented Jun 25, 2015

During a movement of a node other items could be affected (change their position). I mark these nodes as dirty and pass them to onchange.

@jffaust
Copy link
Contributor Author

jffaust commented Jun 25, 2015

The logic of dirty nodes seems good. The only thing left to do would be to make nodes dirty only if they actually changed position or size.

Good job on the awesome library by the way!

@troolee
Copy link
Member

troolee commented Jun 25, 2015

I will.

Thank you!

@cvillemure
Copy link
Contributor

The dirty concept seems a bit hard to implement / use.

If I have a one column layout with two widget of the same size and swap them. Without an ID (which the library does not support) how would you represent that in the resulting items ?

Also, are new and removed nodes also considered dirty? I would assume that the onchange event does not only trigger for resize / move but also for add and remove (#167).

I would suggest to continue sending all of the grid's items and let the user handle the changes as he needs.

Unless I'm wrong in my understanding of the library ... correct me if I'm wrong.

@radiolips
Copy link
Member

In the case that you mention, if both widgets have changed position, then both will be returned as changed. As @troolee fixed this in #167, I'm closing the ticket. It does return only changed items, but that's how it is designed to work.

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

No branches or pull requests

4 participants