Gathering detailed insights and metrics for fzb-v-viewer
Gathering detailed insights and metrics for fzb-v-viewer
Gathering detailed insights and metrics for fzb-v-viewer
Gathering detailed insights and metrics for fzb-v-viewer
Image viewer component for vue, supports rotation, scale, zoom and so on, based on viewer.js
npm install fzb-v-viewer
Typescript
Module System
Min. Node Version
Node Version
NPM Version
Vue (73.09%)
TypeScript (18.8%)
HTML (7.53%)
Shell (0.41%)
JavaScript (0.18%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
2,587 Stars
96 Commits
297 Forks
15 Watchers
8 Branches
6 Contributors
Updated on Jul 16, 2025
Latest Version
1.0.2
Package Id
fzb-v-viewer@1.0.2
Unpacked Size
45.40 kB
Size
12.73 kB
File Count
6
NPM Version
8.15.0
Node Version
16.17.0
Published on
Feb 06, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
59
Image viewer component for vue, supports rotation, scale, zoom and so on, based on viewer.js
.css
file:import 'viewerjs/dist/viewer.css'
Install from NPM
1npm install v-viewer
To use v-viewer
, simply import it and the css
file, and call Vue.use()
to install.
1<template> 2 <div> 3 <!-- directive --> 4 <div class="images" v-viewer> 5 <img v-for="src in images" :key="src" :src="src"> 6 </div> 7 <!-- component --> 8 <viewer :images="images"> 9 <img v-for="src in images" :key="src" :src="src"> 10 </viewer> 11 <!-- api --> 12 <button type="button" @click="show">Click to show</button> 13 </div> 14</template> 15<script> 16 import 'viewerjs/dist/viewer.css' 17 import VueViewer from 'v-viewer' 18 import Vue from 'vue' 19 Vue.use(VueViewer) 20 export default { 21 data() { 22 return { 23 images: [ 24 "https://picsum.photos/200/200", 25 "https://picsum.photos/300/200", 26 "https://picsum.photos/250/200" 27 ] 28 }; 29 }, 30 methods: { 31 show() { 32 this.$viewerApi({ 33 images: this.images, 34 }) 35 }, 36 }, 37 } 38</script>
1<link href="//unpkg.com/viewerjs/dist/viewer.css" rel="stylesheet"> 2<script src="//unpkg.com/vue/dist/vue.js"></script> 3<script src="//unpkg.com/viewerjs/dist/viewer.js"></script> 4<script src="//unpkg.com/v-viewer/dist/v-viewer.js"></script> 5<script> 6 Vue.use(VueViewer.default) 7</script>
1var VueViewer = require('VueViewer')
1require(['VueViewer'], function (VueViewer) {});
Just add the directive v-viewer
to any element, then all img
elements in it will be handled by viewer
.
You can set the options like this: v-viewer="{inline: true}"
Get the element by selector and then use el.$viewer
to get the viewer
instance if you need.
1<template> 2 <div> 3 <div class="images" v-viewer="{movable: false}"> 4 <img v-for="src in images" :src="src" :key="src"> 5 </div> 6 <button type="button" @click="show">Show</button> 7 </div> 8</template> 9<script> 10 import 'viewerjs/dist/viewer.css' 11 import { directive as viewer } from "v-viewer" 12 export default { 13 directives: { 14 viewer: viewer({ 15 debug: true, 16 }), 17 }, 18 data() { 19 return { 20 images: [ 21 "https://picsum.photos/200/200", 22 "https://picsum.photos/300/200", 23 "https://picsum.photos/250/200" 24 ] 25 }; 26 }, 27 methods: { 28 show () { 29 const viewer = this.$el.querySelector('.images').$viewer 30 viewer.show() 31 } 32 } 33 } 34</script>
The viewer
instance will be created only once after the directive binded.
If you're sure the images inside this element won't change again, use it to avoid unnecessary re-render.
1<div class="images" v-viewer.static="{inline: true}"> 2 <img v-for="src in images" :src="src" :key="src"> 3</div>
The viewer
instance will be updated by update
method when the source images changed (added, removed or sorted) by default.
If you encounter any display problems, try rebuilding instead of updating.
1<div class="images" v-viewer.rebuild="{inline: true}"> 2 <img v-for="src in images" :src="src" :key="src"> 3</div>
You can simply import the component and register it locally too.
Use scoped slot to customize the presentation of your images.
1<template> 2 <div> 3 <viewer :options="options" :images="images" 4 @inited="inited" 5 class="viewer" ref="viewer" 6 > 7 <template #default="scope"> 8 <img v-for="src in scope.images" :src="src" :key="src"> 9 {{scope.options}} 10 </template> 11 </viewer> 12 <button type="button" @click="show">Show</button> 13 </div> 14</template> 15<script> 16 import 'viewerjs/dist/viewer.css' 17 import { component as Viewer } from "v-viewer" 18 export default { 19 components: { 20 Viewer 21 }, 22 data() { 23 return { 24 images: [ 25 "https://picsum.photos/200/200", 26 "https://picsum.photos/300/200", 27 "https://picsum.photos/250/200" 28 ] 29 }; 30 }, 31 methods: { 32 inited (viewer) { 33 this.$viewer = viewer 34 }, 35 show () { 36 this.$viewer.show() 37 } 38 } 39 } 40</script>
Array
Array
You can replace images
with trigger
, to accept any type of prop.
when the trigger
changes, the component will re-render the viewer.
1<viewer :trigger="externallyGeneratedHtmlWithImages"> 2 <div v-html="externallyGeneratedHtmlWithImages"/> 3</viewer>
Boolean
false
The viewer instance will be updated by update
method when the source images changed (added, removed or sorted) by default.
If you encounter any display problems, try rebuilding instead of updating.
1<viewer 2 ref="viewer" 3 :options="options" 4 :images="images" 5 rebuild 6 class="viewer" 7 @inited="inited" 8> 9 <template #default="scope"> 10 <img v-for="src in scope.images" :src="src" :key="src"> 11 {{scope.options}} 12 </template> 13</viewer>
Viewer
Listen for the inited
event to get the viewer
instance, or use this.refs.xxx.$viewer
.
Only available in modal mode.
You can call the function: this.$viewerApi({options: {}, images: []})
to show gallery without rendering the img
elements yourself.
The function returns the current viewer instance.
1<template> 2 <div> 3 <button type="button" class="button" @click="previewURL">URL Array</button> 4 <button type="button" class="button" @click="previewImgObject">Img-Object Array</button> 5 </div> 6</template> 7<script> 8 import 'viewerjs/dist/viewer.css' 9 import { api as viewerApi } from "v-viewer" 10 export default { 11 data() { 12 sourceImageURLs: [ 13 'https://picsum.photos/200/200?random=1', 14 'https://picsum.photos/200/200?random=2', 15 ], 16 sourceImageObjects: [ 17 { 18 'src':'https://picsum.photos/200/200?random=3', 19 'data-source':'https://picsum.photos/800/800?random=3' 20 }, 21 { 22 'src':'https://picsum.photos/200/200?random=4', 23 'data-source':'https://picsum.photos/800/800?random=4' 24 } 25 ] 26 }, 27 methods: { 28 previewURL () { 29 // If you use the `app.use` full installation, you can use `this.$viewerApi` directly like this 30 const $viewer = this.$viewerApi({ 31 images: this.sourceImageURLs 32 }) 33 }, 34 previewImgObject () { 35 // Or you can just import the api method and call it. 36 const $viewer = viewerApi({ 37 options: { 38 toolbar: true, 39 url: 'data-source', 40 initialViewIndex: 1 41 }, 42 images: this.sourceImageObjects 43 }) 44 } 45 } 46 } 47</script>
Refer to viewer.js.
String
viewer
If you need to avoid name conflict, you can import it like this:
1<template> 2 <div> 3 <!-- directive name --> 4 <div class="images" v-vuer="{movable: false}"> 5 <img v-for="src in images" :src="src" :key="src"> 6 </div> 7 <button type="button" @click="show">Show</button> 8 <!-- component name --> 9 <vuer :images="images"> 10 <img v-for="src in images" :src="src" :key="src"> 11 </vuer> 12 </div> 13</template> 14<script> 15 import 'viewerjs/dist/viewer.css' 16 import Vuer from 'v-viewer' 17 import Vue from 'vue' 18 Vue.use(Vuer, {name: 'vuer'}) 19 export default { 20 data() { 21 return { 22 images: [ 23 "https://picsum.photos/200/200", 24 "https://picsum.photos/300/200", 25 "https://picsum.photos/250/200" 26 ] 27 }; 28 }, 29 methods: { 30 show () { 31 // viewerjs instance name 32 const vuer = this.$el.querySelector('.images').$vuer 33 vuer.show() 34 // api name 35 this.$vuerApi({ 36 images: this.images 37 }) 38 } 39 } 40 } 41</script>
Object
undefined
If you need to set the viewer default options, you can import it like this:
1import VueViewer from 'v-viewer' 2import Vue from 'vue' 3Vue.use(VueViewer, { 4 defaultOptions: { 5 zIndex: 9999 6 } 7})
And you can reset the default options at any other time:
1import VueViewer from 'v-viewer' 2import Vue from 'vue' 3Vue.use(VueViewer) 4VueViewer.setDefaults({ 5 zIndexInline: 2017 6})
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
3 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 4
Reason
Found 2/25 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
17 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More