-
Notifications
You must be signed in to change notification settings - Fork 29
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
Conversation
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.
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) { |
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.
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)) { |
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.
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) { |
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.
Some TSDoc here would be helpful explaining when to call and why this criteria is used.
if (this.props.onCancelPan) { | ||
this.props.onCancelPan(); | ||
} |
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.
if (this.props.onCancelPan) { | |
this.props.onCancelPan(); | |
} | |
this.props.onCancelPan?.(); |
Or make the default prop an empty function?
Hello - thank you for building NebulaGL /
editable-layers
, it is a fantastic library.This PR contains two small changes:
onCancelPan
prop toeditable-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.event.cancelPan()
invocations for a variety ofEditModes
, ensuringevent.cancelPan
is being called at the appropriate time