npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-svg-pan-zoom

v2.1.0

Published

Vue component for svg-pan-zoom

Downloads

5,342

Readme

vue-svg-pan-zoom : Vue 3 component for SVG-Pan-Zoom

This module is a very simple Vue 3 component providing the goodness of SVG-Pan-Zoom for SVG elements.

/!\ WARNING: the module is young, basic, probably will have its API change with no notice, and likely to have bugs. Use at your own risk, send patches for my eternal gratitude.

Basic Use

In a Single File Component:

<template>
  <SvgPanZoom
    style="width: 500px; height: 500px; border:1px solid black;"
    :zoomEnabled="true"
    :controlIconsEnabled="true"
    :fit="false"
    :center="true"
  >
    <svg>
      <circle x="10" y="10" r="5" />
    </svg> </SvgPanZoom
  >`
</template>

<script>
import SvgPanZoom from "vue-svg-pan-zoom";

export default {
  components: { SvgPanZoom }
};
</script>

Notes

Currently the SvgPanZoom component only works with a svg child -- embed won't work.

Props

SvgPanZoom accepts as props most svg-pan-zoom options:

| attribute | default | | ------------------------- | ------------------------ | | zoomEnabled | true | | controlIconsEnabled | false | | fit | true | | panEnabled | true | | dblClickZoomEnabled | true | | mouseWheelZoomEnabled | true | | preventMouseEventsDefault | true | | contain | false | | center | true | | viewportSelector | .svg-pan-zoom_viewport | | zoomScaleSensitivity | 0.2 | | minZoom | 0.5 | | maxZoom | 10 | | refreshRate | auto |

| event | arguments | | ------------------------- | ---------------------------------------------------------- | | beforeZoom | (oldScale: number, newScale: number) | | onZoom | (newScale: number) | | beforePan | (oldPan: SvgPanZoom.Point, newPan: SvgPanZoom.Point) | | onPan | (newPan: SvgPanZoom.Point) | | onUpdatedCTM | (newCTM: SVGMatrix) | | created | (spz: SvgPanZoom.Instance) | | thumbnailCreated | (spz: SvgPanZoom.Instance) |

svgpanzoom object

To access the created svgpanzoom javascript object, you can listen to the created event on the SvgPanZoom component.

<template>
  <div>
    <input type="button" value="center me" @click="center" />
    <SvgPanZoom
      style="width: 500px; height: 500px; border:1px solid black;"
      :fit="false"
      @created="registerSvgPanZoom"
    >
      <RawTiger />
    </SvgPanZoom>
  </div>
</template>

<script>
import RawTiger from "./RawTiger.vue";
import SvgPanZoom from "vue-svg-pan-zoom";

export default {
  components: { SvgPanZoom, RawTiger },
  data: () => ({ svgpanzoom: null }),
  methods: {
    registerSvgPanZoom(svgpanzoom) {
      this.svgpanzoom = svgpanzoom;
    },
    center() {
      if (!this.svgpanzoom) return;

      this.svgpanzoom.center();
    }
  }
};
</script>

Use with thumbnails

In a Single File Component:

<template>
  <SvgPanZoom style="width: 300px; height: 500px; border:1px solid black; ">
    <template #default>
      <svg>...</svg>
    <template>
    <template #thumbnail>...</template>
  </SvgPanZoom>
</template>

<script>
import SvgPanZoom from "vue-svg-pan-zoom";

export default {
  components: { SvgPanZoom }
};
</script>

Just like the main SvgPanZoom component, the thumbnail slot needs to be assigned to a svg node -- embed won't work.

Storybook demos

To run Storybook stories duplicating the demos of the main SVG-Pan-Zoom project, do

$ yarn install --dev
$ yarn storybook