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

Default cursor behavior (flickering) #579

Closed
wafisher opened this issue Aug 17, 2018 · 4 comments
Closed

Default cursor behavior (flickering) #579

wafisher opened this issue Aug 17, 2018 · 4 comments

Comments

@wafisher
Copy link
Contributor

I'd like for the cursor to be the -webkit-grab type while it's over anything but a marker. And for it turn into a pointer when it's over a (clickable) marker.

What I see instead is that the cursor flickers whenever it passes over a feature, though I'm not sure how react-map-gl defines a feature — it seems quite broadly. The relevant code in the repo is here. And here's a video I took of the behavior.

The examples confuse me because the author explicitly sets the cursor to be a crosshair. When I disable the effect of that in DevTools, the examples behave similarly strangely (as shown in the video).

Any insight into how to create the desired behavior?

Thanks,
Will

@Pessimistress
Copy link
Collaborator

You can provide your own getCursor prop to the map component. This is the default:
https://github.com/uber/react-map-gl/blob/fbdcbf389166965646b0483d8ce31d41b8ba929c/src/components/interactive-map.js#L114

@wafisher
Copy link
Contributor Author

wafisher commented Aug 22, 2018

Great, so this is intended behavior (per repo authors). For anyone else wanting to fix/change this, I added this to ReactMapGL:

getCursor={({isDragging, isHovering}) => isDragging ? config.CURSOR.GRABBING : config.CURSOR.GRAB}

and copied react-map-gl/src/config.js into my src/ since create-react-app was having issues with me importing it directly.

@chriszrc
Copy link

chriszrc commented Aug 22, 2022

@Pessimistress The docs still say that cursor only accepts a string:

https://visgl.github.io/react-map-gl/docs/api-reference/map#cursor

Had to dig up this issue to realize if I provide a custom cursor, that I also need to provide this custom fn.

[EDIT] oh, so now I'm realizing all of this is outdated. The custom cursor example doesn't cover leaving in the place the default cursor behavior:

https://github.com/visgl/react-map-gl/blob/7.0-release/examples/custom-cursor/src/app.tsx

Am I to assume we have to implement onDragStart, onDragEtc... to make this work normally again?

@chriszrc
Copy link

chriszrc commented Oct 11, 2022

@Pessimistress Any word here on how to preserve the default isDragging cursor handling and also use a custom cursor for layer features? For now, I'm not use the react-mapbox-gl cursor property and instead using an event handler with "onMouseMove", that sets the cursor manually on the canvas:

mapRef!.current!.getCanvas().style.cursor = "pointer";
...
mapRef!.current!.getCanvas().style.cursor = "";

This preserves the default grab/grabbing behavior

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

No branches or pull requests

3 participants