fixed callbacks types#1096
Merged
adumesny merged 2 commits intogridstack:developfrom Dec 17, 2019
adumesny:develop
Merged
Conversation
* 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;
* 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
This was referenced Dec 17, 2019
Closed
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
added, removed, changeor combination if adding a node require also to change its (x,y) for example(we use to always get 'change' duplicated callback)
batchUpdate()before calling a bunch ofaddWidget()and get a single event callback (more efficient).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...
n._dirty = n._origY != newY;(the difference in callbacks noise of 0.5.5 vs this code is UDGE for serialize.html as an example)
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
yarn test)