Add custom SVG cursors and update cursor handling
- Introduced new SVG cursor assets: cross, default, export, move, open, pen, and pointing. - Implemented SCSS styles for cursor usage in the scene container, defining specific cursors for different modes (draw, pointer, pen, measure, hand). - Enhanced cursor functionality by adding a utility function to handle canvas cursor changes based on user actions, mapping specific actions to corresponding cursor styles.
This commit is contained in:
31
app/src/utils/handleCanvasCursors.ts
Normal file
31
app/src/utils/handleCanvasCursors.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
export const handleCanvasCursors = (name: string) => {
|
||||
const canvas = document.getElementById('work-space-three-d-canvas');
|
||||
if (!canvas) return;
|
||||
|
||||
const cursorMap: Record<string, string> = {
|
||||
'draw-wall': 'draw',
|
||||
'draw-aisle': 'draw',
|
||||
'draw-zone': 'draw',
|
||||
'draw-floor': 'draw',
|
||||
measure: 'measure',
|
||||
delete: 'pointer',
|
||||
pen: 'pen',
|
||||
'free-hand': 'hand',
|
||||
// Add more mappings as needed
|
||||
};
|
||||
|
||||
const validCursorClasses = new Set(Object.values(cursorMap));
|
||||
|
||||
// Remove previously applied cursor-related classes
|
||||
canvas.classList.forEach((cls) => {
|
||||
if (validCursorClasses.has(cls)) {
|
||||
canvas.classList.remove(cls);
|
||||
}
|
||||
});
|
||||
|
||||
// Add the new cursor class
|
||||
const newCursorClass = cursorMap[name];
|
||||
if (newCursorClass) {
|
||||
canvas.classList.add(newCursorClass);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user