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-panzoom

v1.1.6

Published

Vue plugin to zoom/pan dom elements

Downloads

45,861

Readme

vue-panzoom

This is a Vue.js port of panzoom, an extensible, mobile friendly pan and zoom framework (supports DOM and SVG).

Demo

Installation

Using npm

npm install vue-panzoom --save

Using yarn

yarn add vue-panzoom

Usage

main.js

// import Vuejs
import Vue from 'vue'
import App from './App.vue'

// import vue-panzoom
import panZoom from 'vue-panzoom'

// install plugin
Vue.use(panZoom);

new Vue({
  render: h => h(App),
}).$mount('#app')

App.vue

<template>
    <div id="app">
        <!-- apply to an image -->
        <panZoom>
            <img src="https://picsum.photos/300">
        </panZoom>

        <!-- apply to regular dom elements -->
        <panZoom>
            <p>You can zoom me</p>
        </panZoom>

        <!-- apply to svg -->
        <panZoom selector="#g1">
            <svg height="210" width="400">
                <g id="g1">
                    <path d="M150 0 L75 200 L225 200 Z" />
                </g>
            </svg>
        </panZoom>
    </div>
</template>

Changing the component's name

If you wish to change the name of the vue component from the default panZoom, you pass an option to the plugin like so:

Vue.use(panZoom, {componentName: 'yourPanZoom'});

and then use in your vue template like so:

<yourPanZoom></yourPanZoom>

Attributes

selector

Use this to specify an element within the scope of vue-panzoom component instance, to apply panZoom to. Default is the first root element of the vue-panzoom component. It accepts standard css selector specification.

<panZoom selector=".zoomable">
  <div class="not-zoomable">I cannot be zoomed and panned</div>
  <div class="zoomable">I can be zoomed and panned</div>
</panZoom>

Options

The options prop is used to define panzoom options. All panzoom options are supported

<panZoom :options="{minZoom: 0.5, maxZoom: 5}"></panZoom>

Events

You can listen to specific events in the lifecycle of a vue-panzoom instance. For example, in the code below the function onPanStart will be called when pan begins

<panZoom @panstart="onPanStart"></panZoom>

Another way to listen to events within the init event's callback, when you know for sure everything is ready and the panzoom instance is available. For example

<panZoom @init="onInit"></panZoom>
onInit: function(panzoomInstance, id) {
  panzoomInstance.on('panstart', function(e){
    console.log(e);
  });
}

init event

This event is fired when the vue-panzoom instance has been initialized successfully. For example:

<panZoom @init="onInit"></panZoom>

panzoom events

All events supported by panzoom are also supported here.

upgrading from 1.1.3 to 1.1.4

Version 1.1.4 uses "rollup-plugin-vue": "^6.0.0", which requires Vue 3. For projects using Vue 2, downgrade to 1.1.3, e.g.:

npm install [email protected]