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
Add unsnap event #15494
base: main
Are you sure you want to change the base?
Add unsnap event #15494
Conversation
📦 Preview the website for this branch here: https://deploy-preview-15494--ol-site.netlify.app/. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution, @eklauberg. See my in-line comments for suggested changes.
* @type {SnappedInfo|null} | ||
* @private | ||
* @description Holds information about the last snapped state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @type {SnappedInfo|null} | |
* @private | |
* @description Holds information about the last snapped state. | |
* Holds information about the last snapped state. | |
* @type {SnappedInfo|null} | |
* @private |
areSnapDataEqual_(data1, data2) { | ||
return ( | ||
data1.vertex[1] === data2.vertex[1] && | ||
data1.feature?.getId() === data2.feature?.getId() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Features do not need an id, but the feature reference will be the same if the features are the same
data1.feature?.getId() === data2.feature?.getId() | |
data1.feature === data2.feature |
this.dispatchEvent(new SnapEvent(SnapEventType.UNSNAP, this.snapped_)); | ||
} | ||
|
||
if (!this.snapped_ || !this.areSnapDataEqual_(this.snapped_, result)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of calling areSnapDataEqual_()
again here, you could store it in a variable above.
*/ | ||
areSnapDataEqual_(data1, data2) { | ||
return ( | ||
data1.vertex[1] === data2.vertex[1] && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'll want to check equality for the segment instead. I'd expect an unsnap
event only when snapping leaves a segment, not whenever I move the cursor.
data1.vertex[1] === data2.vertex[1] && | |
data1.segment === data2.segment && |
Resolve issue: #15404