You've already forked obsidian-visualiser
New Canvas zoom with dbl click and starting to work on tag API
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user