jarvisniu / vue-zoomer

Zoom the image or other thing with mouse or touch
MIT License
150 stars 38 forks source link

vue-zoomer

Zoom the image or other thing with mouse or touch

For Vue 3

This library has released a Vue 3 beta version here.

Demo

Usage

Install:

npm install vue-zoomer

Import and register globally:

import Vue from 'vue'
import VueZoomer from 'vue-zoomer'

Vue.use(VueZoomer)

Import and register locally (after v0.3.10):

<!-- page1.vue -->
<script>
import VueZoomer from 'vue-zoomer'

export default {
  components: {
    VZoomer: VueZoomer.Zoomer,
    VZoomerGallery: VueZoomer.Gallery,
  },
}
</script>

You can also import the source files (after v0.3.10), rather than the minified umd bundle, for better debugging experience:

import VueZoomer from 'vue-zoomer/src'

Single usage:

<v-zoomer style="width: 500px; height: 500px; border: solid 1px silver;">
  <img
    src="https://github.com/jarvisniu/vue-zoomer/raw/master/assets/landscape-1.jpg"
    style="object-fit: contain; width: 100%; height: 100%;"
  >
</v-zoomer>

Gallery usage:

<v-zoomer-gallery
  style="width: 100vw; height: 100vh;"
  :list="['a.jpg', 'b.jpg', 'c.jpg']"
  v-model="selIndex"
></v-zoomer-gallery>

API

<v-zoomer> Props

<v-zoomer> Methods

<v-zoomer-gallery> Props

<v-zoomer-gallery> Methods

License

MIT