Reset zoom on preview change

This commit is contained in:
Austin Mroz
2025-12-27 19:09:23 -08:00
parent 7051b5e491
commit 63ad1b289b

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, ref, useTemplateRef } from 'vue'
import { computed, ref, useSlots, useTemplateRef, watch } from 'vue'
const zoomPane = useTemplateRef('zoomPane')
@@ -7,6 +7,17 @@ const zoom = ref(1.0)
const panX = ref(0.0)
const panY = ref(0.0)
const slots = useSlots()
watch(
() => slots.default?.(),
() => {
zoom.value = 1
panX.value = 0
panY.value = 0
}
)
function handleWheel(e: WheelEvent) {
const zoomPaneEl = zoomPane.value
if (!zoomPaneEl) return