• Stars
    star
    262
  • Rank 156,136 (Top 4 %)
  • Language Vue
  • License
    MIT License
  • Created over 6 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An Mobile-First image viewer for Vue3 / 一个移动端优先的 Vue3 图片预览插件

img-vuer

For Vue2: https://github.com/ssshooter/img-vuer/tree/legacy

An Mobile-First image viewer for Vue3

中文 README


  • 🙆‍♀️ Easy to use
  • 👉 Swipe gesture
  • 🔍 Zoom gesture
  • Now you can use thumbnail~
  • Gallery hide when the physical back button is pressed (android device only)
  • Fix blurry after using scale()
  • 💻 compatible with PC

Now you can use both Mobile and PC Browser 😆

live demo

or scan the QRcode

Install

npm i img-vuer3 --save

Usage

// import img-vuer and install
import gallery from 'img-vuer3'
import 'img-vuer3/dist/style.css'

app.use(gallery, {
  swipeThreshold: 150, // default 100
  isIndexShow: true, // show image index, default true
  useCloseButton: true, // trigger gallery close with close button, default true
  preload: true, // preload images in the same group, default true
  sliderBackgroundColor: 'rgba(0,0,0,0.6)',
  sliderZIndex: 1001,
})
<!-- add direact to <img> -->
<img v-gallery :src="..." />

<!-- group images -->
<img v-gallery:groupName :src="..." />
<img v-gallery:groupName :src="..." />
<img v-gallery:groupName :src="..." />

<!-- OR (dynamic bind) -->
<img v-gallery="'groupName'" :src="..." />

<!-- use thumbnail, new in 0.11.0 -->
<img v-gallery :src="thumbnailSrc" data-large="originSrc" />

<!-- trigger close gallery, new in 0.14.0 -->
<button @click="$imgVuer.close()">close</button>

API

api arg description
close() / close the viwer
onIndexChange() cb $imgVuer.onIndexChange((newVal, oldVal)=>{...})
onToggle() cb on close or on open $imgVuer.onToggle((newVal, oldVal)=>{...})
changeBGColor() color change the background color of viwer $imgVuer.changeBGColor('#fff')
next() / switch to next image $imgVuer.next()
prev() / switch to previous image $imgVuer.prev()
getCurrentIndex() / /

Development

npm install

npm run dev

npm run build-lib

Troubleshooting

Abnormal page scale

Add meta

<meta
  name="viewport"
  content="width=device-width, initial-scale=1,user-scalable=0, maximum-scale=1"
/>

for a large number of large images

If you group a large number of large images, img-vuer will load all image in the same group, so it will cause unnecessary mobile data traffic and slow the page down.

You can use preload option in this situation and img-vuer will only load the image you watched.

key

Should not use index as key for the component which is added v-gallery.

License

MIT

More Repositories

1

mind-elixir-core

⚗ Mind Elixir is a JavaScript, framework-agnostic mind map core.
TypeScript
1,957
star
2

nippon-color

copy nippon-color PWA build with vue-cli 3
JavaScript
112
star
3

MyDiary-Vue

vue构建的日记应用 来源于「君の名は」( Mydiary created with Vue2 )
Vue
85
star
4

mongoose-doc-cn

mongoose 5.0 中文文档
JavaScript
81
star
5

canvas-img-process

html5 canvas image process ( 3*3 kernel ) canvas卷积核测试 canvas图片后期
Vue
35
star
6

Creepy.CSS

a creepy style UI
CSS
32
star
7

Front-End-EXP

前端的一些坑,一些记录,一些冷知识
29
star
8

PSN-node-displayer

Come on! Show your PSN trophy!
Vue
23
star
9

syncHime

Chrome 同步看视频插件
JavaScript
18
star
10

img-uploader

image-uploader
Vue
16
star
11

gatsby-theme-usubeni

Gatsby Theme For Blog
JavaScript
12
star
12

MyDiary-API

restful API for MyDiary
JavaScript
10
star
13

export-xmind

You can use `@mind-elixir/export-xmind` to export a `.xmind` file.
JavaScript
8
star
14

gatsby-blog-starter

yet another Gatsby blog starter
JavaScript
8
star
15

MyDiary

The diary app in the movie Your Name (Japanese: 君の名は。 Hepburn: Kimi no Na wa. Chinese:你的名字)
JavaScript
8
star
16

caption-blocker

caption blocker 是一个简易字幕遮挡工具
JavaScript
4
star
17

mind-elixir-cloud

Vue
4
star
18

call-map

Check function outgoing/incoming calls as a Mind Map.
TypeScript
4
star
19

mind-elixir-react

react component of mind elixir
JavaScript
3
star
20

node-menu

A node menu plugin of mind-elixir
TypeScript
3
star
21

node-menu-neo

TypeScript
2
star
22

gbf.auto.ahk

granblue fantasy auto script running with autohotkey
AutoHotkey
2
star
23

PSN-node

APIs for fetching psn trophy information
JavaScript
2
star
24

mind-elixir-vue

JavaScript
2
star
25

mark-elixir

TypeScript
1
star
26

photoshop

1
star
27

nest-mongodb-starter

1
star
28

pixivDownloader

输入id,下载大图
JavaScript
1
star
29

v-finger

v-finger
JavaScript
1
star
30

ac-exchange-system

一个未命名甚至未发布的动森大头菜交易系统
Vue
1
star
31

nippon-color-native

nippon-color with react native
JavaScript
1
star
32

lightweight-tour-guide

超轻量网页引导、教程直接复制直接用
JavaScript
1
star
33

mind-elixir-plugin-template

JavaScript
1
star