From 38cd683e87243b7cabc167eac8b3bab2c4604d43 Mon Sep 17 00:00:00 2001 From: Julian Lawrance Date: Sat, 27 Apr 2024 10:53:31 +0100 Subject: [PATCH] Implement panzoom for knockout bracket in modal --- src/components/modals/BracketModal.vue | 82 ++++++++++++-------------- src/composables/useCursorGrab.ts | 8 +-- 2 files changed, 40 insertions(+), 50 deletions(-) diff --git a/src/components/modals/BracketModal.vue b/src/components/modals/BracketModal.vue index a46451e..9fc4f60 100644 --- a/src/components/modals/BracketModal.vue +++ b/src/components/modals/BracketModal.vue @@ -1,5 +1,6 @@ @@ -73,35 +88,12 @@ const zoomClass = computed(() => `zoom-${currentPercentage.value}`) max-width: 90vw; } -#bracketDiv { - transform-origin: center center; -} - -#bracketDiv.zoom-25 { - transform: scale(0.25); -} - -#bracketDiv.zoom-50 { - transform: scale(0.5); -} - -#bracketDiv.zoom-75 { - transform: scale(0.75); -} - -#bracketDiv.zoom-125 { - transform: scale(1.25); -} - -#bracketDiv.zoom-150 { - transform: scale(1.5); -} - -#bracketDiv.zoom-175 { - transform: scale(1.75); +.grab { + cursor: grab!important; } -#bracketDiv.zoom-200 { - transform: scale(2); +/* BUG: this is not applying when we put the mouse down on the panzoom child */ +.grabbing { + cursor: grabbing!important; } diff --git a/src/composables/useCursorGrab.ts b/src/composables/useCursorGrab.ts index 8b91cde..2e7d5ba 100644 --- a/src/composables/useCursorGrab.ts +++ b/src/composables/useCursorGrab.ts @@ -1,18 +1,16 @@ -import { computed, ref, type CSSProperties } from "vue" +import { computed, ref } from "vue" export const useCursorGrab = () => { const isGrabbing = ref(false) - const cursorStyle = computed(() => ({ - cursor: isGrabbing.value ? "grabbing" : "grab" - })) + const cursorClass = computed(() => isGrabbing.value ? "grabbing" : "grab") const setGrabbing = (v: boolean) => { isGrabbing.value = v } return { - cursorStyle, + cursorClass, setGrabbing, } }