New Canvas zoom with dbl click and starting to work on tag API

This commit is contained in:
2024-09-03 16:42:57 +02:00
parent c091a6d261
commit 2b293a0c1a
16 changed files with 353 additions and 77 deletions

View File

@@ -10,11 +10,26 @@ const props = defineProps<Props>();
let dragging = false, posX = 0, posY = 0, dispX = ref(0), dispY = ref(0), minZoom = ref(0.1), zoom = ref(0.5);
let lastDistance = 0;
let lastClickTime = 0;
const onPointerDown = (event: PointerEvent) => {
if (event.isPrimary === false) return;
dragging = true;
const now = performance.now();
if(now - lastClickTime < 500 && Math.abs(event.clientX - posX) < 20 && Math.abs(event.clientY - posY) < 20)
{
if(event.ctrlKey)
{
zoom.value = clamp(zoom.value * 0.9, minZoom.value, 3);
}
else
{
zoom.value = clamp(zoom.value * 1.1, minZoom.value, 3);
}
}
lastClickTime = now;
posX = event.clientX;
posY = event.clientY;