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

fixed callbacks types #1096

Merged
merged 2 commits into from
Dec 17, 2019
Merged

fixed callbacks types #1096

merged 2 commits into from
Dec 17, 2019

Conversation

adumesny
Copy link
Member

@adumesny adumesny commented Dec 17, 2019

Description

  • fixed callbacks to get either added, removed, change or combination if adding a node require also to change its (x,y) for example
    (we use to always get 'change' duplicated callback)
  • you can now call batchUpdate() before calling a bunch of addWidget() and get a single event callback (more efficient).
  • update two.hml to show callbacks (good debuging setup)
    Note: moving items in float=false will still sometimes have change CB with all items, not just those that moved. this is due to how _fixCollisions() does this
    if (!this.float && !hasLocked) { nn = {x: 0, y: node.y, width: this.column, height: node.height}; }
    causing all items to temporarly move. I don't claim to understand that code yet...
  • added a comment for #757 Fixed returning of an array of actually changed widgets #789 as to why _packNodes() can't check for
    n._dirty = n._origY != newY;
  • pass the original nodes for addEvent/removeEvent instead of clones
  • _triggerChangeEvent() no longer forced called (with no data, what's the point ?)
  • commit() calls remove, added, change in that order
  • updated more samples - use batch calls
    (the difference in callbacks noise of 0.5.5 vs this code is UDGE for serialize.html as an example)
  • fixed error when dragging add item over the trash, and then over second grid

Test

best way to test how much better the callback noise is vs before is to run the local
serialize.html copy with these changes. First use
<script src="https://cdn.jsdelivr.net/npm/gridstack@0.5.5/dist/gridstack.all.js"></script>
then the fixed lib code.

Checklist

  • Created tests which fail without the change (if possible)
  • All tests passing (yarn test)
  • Extended the README / documentation, if necessary

* fixed callbacks to get either `added, removed, change` or combination if adding a node require also to change its (x,y) for example
(we use to always get 'change' duplicated callback)
* you can now call `batchUpdate()` before calling a bunch of `addWidget()` and get a single event callback (more efficient).
* update two.hml to show callbacks (good debuging setup)
Note: moving items in float=false will still sometimes have change CB with all items, not just those that moved. this is due to how _fixCollisions() does this
if (!this.float && !hasLocked) {
  nn = {x: 0, y: node.y, width: this.column, height: node.height};
}
causing all items to temporarly move. I don't claim to understand that code yet...
* added a comment for #789 as to why _packNodes() can't check for
n._dirty = n._origY != newY;
@coveralls
Copy link

coveralls commented Dec 17, 2019

Coverage Status

Coverage increased (+0.02%) to 66.685% when pulling 4f6ae38 on adumesny:develop into 8989dfa on gridstack:develop.

* pass the original nodes for addEvent/removeEvent instead of clones
* _triggerChangeEvent() no longer forced called (with no data, what's the point ?)
* commit() calls remove, added, change in that order
* updated more samples - use batch calls
(the difference in callbacks noise of 0.5.5 vs this code is UDGE for serialize.html as an example)
* fixed error when dragging add item over the trash, and then over second grid
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

Successfully merging this pull request may close these issues.

2 participants