Skip to content

Commit

Permalink
Remove double click handlers from nebula layers and edit-modes (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
austintang committed Jun 5, 2020
1 parent 34d72a9 commit 95e8b94
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 40 deletions.
3 changes: 1 addition & 2 deletions examples/advanced/src/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,7 @@ export default class Example extends React.Component<
id: 'basemap',
controller: {
type: MapController,
// @ts-ignore
doubleClickZoom: this.state.mode === 'view' && !this.state.selectionTool,
doubleClickZoom: false,
},
}),
]}
Expand Down
1 change: 0 additions & 1 deletion modules/edit-modes/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export type {
StartDraggingEvent,
StopDraggingEvent,
DraggingEvent,
DoubleClickEvent,
ModeProps,
GuideFeatureCollection,
Viewport,
Expand Down
6 changes: 0 additions & 6 deletions modules/edit-modes/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ export type BasePointerEvent = {
// Represents a click event
export type ClickEvent = BasePointerEvent;

// Represents a double-click event
export type DoubleClickEvent = {
mapCoords: Position;
sourceEvent: any;
};

// Represents an event that occurs when the pointer goes down and the cursor starts moving
export type StartDraggingEvent = BasePointerEvent & {
pointerDownPicks?: Pick[] | null | undefined;
Expand Down
5 changes: 0 additions & 5 deletions modules/layers/src/event-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ export type ClickEvent = {
sourceEvent: any;
};

export type DoubleClickEvent = {
groundCoords: Position;
sourceEvent: any;
};

export type StartDraggingEvent = {
picks: DeckGLPick[];
screenCoords: Position;
Expand Down
26 changes: 4 additions & 22 deletions modules/layers/src/layers/editable-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import {
StopDraggingEvent,
DraggingEvent,
PointerMoveEvent,
DoubleClickEvent,
} from '@nebula.gl/edit-modes';

const EVENT_TYPES = ['anyclick', 'pointermove', 'panstart', 'panmove', 'panend', 'dblclick'];
const EVENT_TYPES = ['anyclick', 'pointermove', 'panstart', 'panmove', 'panend'];

export default class EditableLayer extends CompositeLayer<any> {
static layerName = 'EditableLayer';
Expand All @@ -19,10 +18,6 @@ export default class EditableLayer extends CompositeLayer<any> {
// default implementation - do nothing
}

onDoubleClick(event: DoubleClickEvent) {
// default implementation - do nothing
}

onStartDragging(event: StartDraggingEvent) {
// default implementation - do nothing
}
Expand All @@ -35,7 +30,9 @@ export default class EditableLayer extends CompositeLayer<any> {
// default implementation - do nothing
}

onPointerMove(event: PointerMoveEvent) {} // default implementation - do nothing
onPointerMove(event: PointerMoveEvent) {
// default implementation - do nothing
}
// TODO: implement onCancelDragging (e.g. drag off screen)

initializeState() {
Expand Down Expand Up @@ -113,21 +110,6 @@ export default class EditableLayer extends CompositeLayer<any> {
});
}

_ondblclick({ srcEvent }: any) {
const screenCoords = this.getScreenCoords(srcEvent);
const mapCoords = this.getMapCoords(screenCoords);
// @ts-ignore
const picks = this.getPicks(screenCoords);

this.onDoubleClick({
mapCoords,
// @ts-ignore
screenCoords,
picks,
sourceEvent: srcEvent,
});
}

_onpanstart(event: any) {
const screenCoords = this.getScreenCoords(event.srcEvent);
const mapCoords = this.getMapCoords(screenCoords);
Expand Down
8 changes: 4 additions & 4 deletions modules/main/src/lib/nebula.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ export default class Nebula {
this.props = props;
this.wmViewport = new WebMercatorViewport(this.props.viewport);

// TODO: Properly use pointer events: ['click', 'dblclick', 'pointermove', 'pointerup', 'pointerdown']
['click', 'dblclick', 'mousemove', 'mouseup', 'mousedown'].forEach((name) =>
// TODO: Properly use pointer events: ['click', 'pointermove', 'pointerup', 'pointerdown']
['click', 'mousemove', 'mouseup', 'mousedown'].forEach((name) =>
document.addEventListener(name, this._onMouseEvent, true)
);
}

detach() {
// TODO: Properly use pointer events: ['click', 'dblclick', 'pointermove', 'pointerup', 'pointerdown']
['click', 'dblclick', 'mousemove', 'mouseup', 'mousedown'].forEach((name) =>
// TODO: Properly use pointer events: ['click', 'pointermove', 'pointerup', 'pointerdown']
['click', 'mousemove', 'mouseup', 'mousedown'].forEach((name) =>
document.removeEventListener(name, this._onMouseEvent, true)
);
}
Expand Down

0 comments on commit 95e8b94

Please sign in to comment.