Skip to content
This repository has been archived by the owner on Sep 23, 2023. It is now read-only.

Commit

Permalink
work on pan zoom for canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsandersen committed Jun 20, 2023
1 parent c25062b commit 38aa12d
Show file tree
Hide file tree
Showing 6 changed files with 6,077 additions and 11,746 deletions.
2 changes: 1 addition & 1 deletion components/studio/BannerCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BlockType } from './util/BlockType'
</script>

<template>
<div class="flex justify-center items-center min-w-[150px] min-h-[75px] w-[330px] h-[130px] max-w-[1024px] max-h-[720px] bg-slate-50 text-slate-600 border-2 border-black resize overflow-hidden">
<div class="banner-container flex justify-center items-center min-w-[150px] min-h-[75px] w-[330px] h-[130px] max-w-[1024px] max-h-[720px] bg-slate-50 text-slate-600 border-2 border-black resize overflow-hidden">
<div class="relative h-full w-full">
<StudioUtilBlock :type="BlockType.TEXT" :initial-width="80" data="Yeehaw"></StudioUtilBlock>
</div>
Expand Down
24 changes: 23 additions & 1 deletion components/studio/Workspace.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import Panzoom from '@panzoom/panzoom'
const canvasContainer = ref(null)
onMounted(() => {
console.log("Initializing panzoom")
const element = (canvasContainer.value as unknown) as HTMLElement;
const panzoom = Panzoom(element, {
animate: true,
excludeClass: 'banner-block',
maxScale: 3,
minScale: 0.75
});
element.addEventListener('wheel', panzoom.zoomWithWheel);
console.log("Panzoom initialized");
})
</script>

<template>
<section id="workspace" class="flex w-full justify-center items-center">
<section id="workspace" ref="canvasContainer" class="flex w-full justify-center items-center overflow-hidden">
<StudioBannerCanvas />
</section>
</template>
Expand Down
2 changes: 1 addition & 1 deletion components/studio/util/Block.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const inlineStyles = computed(() => {
</script>

<template>
<div :style="inlineStyles" @mousedown.prevent="handleMouseDown" @mousemove.prevent="handleMouseMove" @mouseup.prevent="handleMouseUp" @mouseover.prevent="handleMouseOver" @mouseleave.prevent="handleMouseLeave" ref="element">
<div :style="inlineStyles" class="banner-block" @mousedown.prevent="handleMouseDown" @mousemove.prevent="handleMouseMove" @mouseup.prevent="handleMouseUp" @mouseover.prevent="handleMouseOver" @mouseleave.prevent="handleMouseLeave" ref="element">
<div :class="innerBlockClasses">
<p v-if="props.type === BlockType.TEXT">{{ props.data }}</p>
<img v-else-if="props.type === BlockType.IMAGE" :src="'data:image/png;base64,' + props.data" />
Expand Down
Loading

0 comments on commit 38aa12d

Please sign in to comment.