Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors in the example #5

Open
alexandrmucha opened this issue Jul 28, 2024 · 0 comments
Open

Errors in the example #5

alexandrmucha opened this issue Jul 28, 2024 · 0 comments

Comments

@alexandrmucha
Copy link

Hello, I found errors in the example that cause the 500 error:

Duplicate attribute:
<circle :cx="composePoint(0.5, 0.5)[0]" :cx="composePoint(0.5, 0.5)[1]" r="5" style="fill: #f00;" />

Bad library name in import:
import 'zoompich/style.css';

Even after fixing these errors it still doesn't work for me. A blank page appears, with no image on it. Can you help me please?

My code in Nuxt framework:

<template>
  <zoompinch
    ref="zoompinchRef"
    v-model:transform="transform"
    :width="1536"
    :height="2048"
    :offset="{ top: 10, right: 10, bottom: 10, left: 10 }"
    :min-scale="0.1"
    :max-scale="10"
    :rotation="true"
    :bounds="false"
    mouse
    touch
    wheel
    gesture
  >
    <template #canvas>
      <img src="https://imagedelivery.net/mudX-CmAqIANL8bxoNCToA/489df5b2-38ce-46e7-32e0-d50170e8d800/public" style="width: 1536px; height: 2048px;" />
    </template>
    <template #matrix="{ composePoint }">
      <svg xmlns="http://www.w3.org/2000/svg" @click="handleClickOnLayer">
        <!-- This circle will stick to the center of the canvas -->
        <circle :cx="composePoint(0.5, 0.5)[0]" :cy="composePoint(0.5, 0.5)[1]" r="5" style="fill: #f00;" />
      </svg>
    </template>
  </zoompinch>
</template>

<script setup lang="ts">
import { Zoompinch } from 'zoompinch';
import 'zoompinch/style.css';

// Just the ref instance in which the component instance will live
const zoompinchRef = ref<InstanceType<typeof ProjectionLayer>>();

// A reactive transform object
const transform = ref({
  x: 0,
  y: 0,
  scale: 1,
  rotate: 1,
});

function handleClickOnLayer(event: MouseEvent) {
  const [x, y] = zoompinchRef.value?.normalizeMatrixCoordinates(event.clientX, event.clientY);

  console.log('clicked at', x, y);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant