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

Adds onCancelPan optional prop and adds more calls to cancelPan #166

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

alex-bain
Copy link
Contributor

Hello - thank you for building NebulaGL / editable-layers, it is a fantastic library.

This PR contains two small changes:

  • Introduces an optional onCancelPan prop to editable-layers, allowing developers to execute their own logic when NebulaGL determines a map panning operation should be cancelled. This enables the event to propagate to a host mapping framework.
  • Adds event.cancelPan() invocations for a variety of EditModes, ensuring event.cancelPan is being called at the appropriate time

Copy link
Contributor

@ibgreen ibgreen left a comment

Choose a reason for hiding this comment

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

The functionality seems solid, though from the perspective of a detached maintainer like myself I wish there was a bit more information added

  • Docs - Perhaps start writing a "skeleton" doc page about how to implement edit modes and add a section about map panning cancellation.
  • Tests - assume it is hard to create a test case for this? Trigger an event and make sure the prop callback is called?

@@ -62,6 +62,10 @@ export class ExtendLineStringMode extends GeoJsonEditMode {

const mapCoords = props.lastPointerMoveEvent && props.lastPointerMoveEvent.mapCoords;

if (!mapCoords) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a comment that explains when this happens?

@@ -61,6 +62,10 @@ export class ExtrudeMode extends ModifyMode {
}

handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {
if (shouldCancelPan(event)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be implemented by every mode? Could it be called by the framework before invoking handleStartDragging?

Do we need a mode writer's guide page in the docs that explains this?

@@ -516,3 +516,7 @@ export function mapCoords(
})
.filter(Boolean);
}

export function shouldCancelPan(event: StartDraggingEvent) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Some TSDoc here would be helpful explaining when to call and why this criteria is used.

Comment on lines +159 to +161
if (this.props.onCancelPan) {
this.props.onCancelPan();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (this.props.onCancelPan) {
this.props.onCancelPan();
}
this.props.onCancelPan?.();

Or make the default prop an empty function?

@ibgreen ibgreen merged commit 22327a2 into visgl:master Dec 9, 2024
1 check passed
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