Skip to content

Commit

Permalink
[feat] Add onMouseMove callback (#2317)
Browse files Browse the repository at this point in the history
Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
Co-authored-by: Ilija Puaca <ipuaca@gmail.com>
  • Loading branch information
igorDykhta and ilijapuaca committed Sep 18, 2023
1 parent 66a6364 commit d28674e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/components/src/kepler-gl.tsx
Expand Up @@ -174,6 +174,7 @@ export const mapFieldsSelector = (props: KeplerGLProps, index: number = 0) => ({
mapStyle: props.mapStyle,
onDeckInitialized: props.onDeckInitialized,
onViewStateChange: props.onViewStateChange,
onMouseMove: props.onMouseMove,
deckGlProps: props.deckGlProps,
uiStateActions: props.uiStateActions,
visStateActions: props.visStateActions,
Expand Down Expand Up @@ -335,6 +336,7 @@ type KeplerGLBasicProps = {
deckGlProps?: object;
onLoadCloudMapSuccess?: OnSuccessCallBack;
onLoadCloudMapError?: OnErrorCallBack;
onMouseMove?: (event: React.MouseEvent & {lngLat?: [number, number]}) => void;
onExportToCloudSuccess?: OnSuccessCallBack;
onExportToCloudError?: OnErrorCallBack;
readOnly?: boolean;
Expand Down
12 changes: 9 additions & 3 deletions src/components/src/map-container.tsx
Expand Up @@ -308,6 +308,8 @@ export interface MapContainerProps {

generateMapboxLayers?: typeof generateMapboxLayers;
generateDeckGLLayers?: typeof computeDeckLayers;

onMouseMove?: (event: React.MouseEvent & {lngLat?: [number, number]}) => void;
}

export default function MapContainerFactory(
Expand Down Expand Up @@ -670,7 +672,8 @@ export default function MapContainerFactory(
index,
mapControls,
theme,
generateDeckGLLayers
generateDeckGLLayers,
onMouseMove
} = this.props;

const {hoverInfo, editor} = visState;
Expand Down Expand Up @@ -755,8 +758,11 @@ export default function MapContainerFactory(
<div
onMouseMove={
primaryMap
? // @ts-expect-error should be deck viewport
event => this.props.visStateActions.onMouseMove(normalizeEvent(event, viewport))
? event => {
onMouseMove?.(event);
// @ts-expect-error should be deck viewport
this.props.visStateActions.onMouseMove(normalizeEvent(event, viewport));
}
: undefined
}
>
Expand Down

0 comments on commit d28674e

Please sign in to comment.