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

Add unsnap event #15494

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add unsnap event #15494

wants to merge 2 commits into from

Conversation

eklauberg
Copy link

Resolve issue: #15404

Copy link

📦 Preview the website for this branch here: https://deploy-preview-15494--ol-site.netlify.app/.

Copy link
Member

@ahocevar ahocevar left a 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.

Comment on lines +223 to +225
* @type {SnappedInfo|null}
* @private
* @description Holds information about the last snapped state.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @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()
Copy link
Member

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

Suggested change
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)) {
Copy link
Member

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] &&
Copy link
Member

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.

Suggested change
data1.vertex[1] === data2.vertex[1] &&
data1.segment === data2.segment &&

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.

None yet

2 participants