mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-28 09:40:16 +01:00
Restructuration of the project folders
This commit is contained in:
23
server/traque-front/hook/useMultipleCircleDraw.jsx
Normal file
23
server/traque-front/hook/useMultipleCircleDraw.jsx
Normal file
@@ -0,0 +1,23 @@
|
||||
"use client";
|
||||
|
||||
export default function useMultipleCircleDraw(circles, addCircle, removeCircle, radius) {
|
||||
|
||||
function isBaddlyPlaced(latlng) {
|
||||
return circles.some(circle => latlng.distanceTo(circle.center) < 2 * circle.radius);
|
||||
}
|
||||
|
||||
function getCircleFromLatlng(latlng) {
|
||||
return circles.find(circle => latlng.distanceTo(circle.center) < circle.radius);
|
||||
}
|
||||
|
||||
function handleLeftClick(e) {
|
||||
if (!isBaddlyPlaced(e.latlng)) addCircle(e.latlng, radius);
|
||||
}
|
||||
|
||||
function handleRightClick(e) {
|
||||
const circle = getCircleFromLatlng(e.latlng);
|
||||
if (circle) removeCircle(circle.id);
|
||||
}
|
||||
|
||||
return { handleLeftClick, handleRightClick };
|
||||
}
|
||||
Reference in New Issue
Block a user