Change drag cursors to grab and show no-drag cursor if needed

This commit is contained in:
Mitchell McCaffrey
2021-06-03 12:25:23 +10:00
parent bac3101886
commit 0a03387bf4
3 changed files with 24 additions and 8 deletions

View File

@@ -47,7 +47,7 @@ export function TileDragProvider({ onDragAdd, children }) {
const [dragId, setDragId] = useState();
const [overId, setOverId] = useState();
const [dragCursor, setDragCursor] = useState("pointer");
const [dragCursor, setDragCursor] = useState("grab");
function handleDragStart({ active, over }) {
setDragId(active.id);
@@ -63,9 +63,9 @@ export function TileDragProvider({ onDragAdd, children }) {
if (over.id.startsWith(UNGROUP_ID_PREFIX)) {
setDragCursor("alias");
} else if (over.id.startsWith(ADD_TO_MAP_ID_PREFIX)) {
setDragCursor("copy");
setDragCursor(onDragAdd ? "copy" : "no-drop");
} else {
setDragCursor("pointer");
setDragCursor("grabbing");
}
}
}
@@ -73,7 +73,7 @@ export function TileDragProvider({ onDragAdd, children }) {
function handleDragEnd({ active, over }) {
setDragId();
setOverId();
setDragCursor("pointer");
setDragCursor("grab");
if (!active || !over || active.id === over.id) {
return;
}