Change cursor on hover - has no affect #130
newguy123-creator
started this conversation in
General
Replies: 3 comments 2 replies
-
That's because Maplibre and Mapbox also have a cursor style. You can aim at the canvas instead of the document body to have priority in the CSS hierarchy. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yes I gathered that. The question therefore is, how can I overrirde it and make my style important? |
Beta Was this translation helpful? Give feedback.
0 replies
-
I like to do it like this: import { useCursor as useCursorDrei } from "@react-three/drei";
import { useMap } from "react-three-map";
export const useCursor = (active: boolean, onPointerOver: string) => {
const map = useMap() as ReturnType<typeof useMap> | undefined;
const defaultCursor = map ? "grab" : "auto";
const cursorStyleContainer = map?.getCanvasContainer() || document.body;
useCursorDrei(active, onPointerOver, defaultCursor, cursorStyleContainer);
}; |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
three
version: 0.169.0@react-three/fiber
version: 8.17.10react-three-map
version: 0.8.2node
version: v20.11.1npm
(oryarn
) version: 10.2.4Problem description:
Usually I can easily add code to my model tag in my canvas to change the cursor to a pointer in a regular R3F app, however this doesnt seem to work in react-three-map. No matter what I do, the cursor stays the "grab" cursor.
Relevant code:
Suggested solution:
Beta Was this translation helpful? Give feedback.
All reactions