├── .editorconfig
├── .eslintignore
├── .eslintrc
├── .github
└── workflows
│ ├── create-release.yml
│ └── gh-pages.yml
├── .gitignore
├── .husky
├── commit-msg
└── pre-commit
├── .lintstagedrc
├── .npmrc
├── CHANGELOG.md
├── LICENSE
├── README.md
├── commitlint.config.cjs
├── example
├── App.vue
├── index.html
├── main.ts
├── public
│ └── favicon.ico
├── views
│ └── example
│ │ ├── ApiExample.vue
│ │ ├── ComponentExample.vue
│ │ ├── DirectiveExample.vue
│ │ └── index.vue
└── vite.config.ts
├── package.json
├── pnpm-lock.yaml
├── src
├── api.ts
├── component.vue
├── directive.ts
├── index.ts
└── shims-vue.d.ts
├── tsconfig.json
├── tsconfig.node.json
├── types
└── index.d.ts
└── vite.config.ts
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 2
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 | node_modules
3 | public
4 | *.md
5 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@antfu",
3 | "rules": {
4 | "curly": "off",
5 | "no-console": "off",
6 | "no-unused-vars": "off",
7 | "@typescript-eslint/no-unused-vars": "off"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/.github/workflows/create-release.yml:
--------------------------------------------------------------------------------
1 | name: CI Create Release
2 |
3 | on:
4 | push:
5 | tags:
6 | - 'v*'
7 | jobs:
8 | build:
9 | name: Create Release
10 | runs-on: ubuntu-latest
11 | steps:
12 | - name: Checkout code
13 | uses: actions/checkout@v3
14 | - name: Create Release
15 | id: create_release
16 | uses: actions/create-release@v1
17 | env:
18 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19 | with:
20 | tag_name: ${{ github.ref }}
21 | release_name: Release ${{ github.ref }}
22 | body: |
23 | Please refer to [CHANGELOG.md](https://github.com/mirari/v-viewer/blob/master/CHANGELOG.md) for details.
24 | draft: false
25 | prerelease: false
26 |
--------------------------------------------------------------------------------
/.github/workflows/gh-pages.yml:
--------------------------------------------------------------------------------
1 | name: Github Pages Deploy
2 | on:
3 | push:
4 | branches:
5 | - master
6 | jobs:
7 | build-and-deploy:
8 | runs-on: ubuntu-latest
9 | steps:
10 | - name: Checkout 🛎️
11 | uses: actions/checkout@v3
12 | - name: Install and Build
13 | run: |
14 | npm i pnpm -g
15 | pnpm i
16 | pnpm run build
17 | pnpm run preview:build
18 | - name: Deploy 🚀
19 | uses: JamesIves/github-pages-deploy-action@v4
20 | with:
21 | branch: gh-pages
22 | folder: example/dist
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 | /example/dist
5 |
6 | # local env files
7 | .env.local
8 | .env.*.local
9 |
10 | # Log files
11 | npm-debug.log*
12 | yarn-debug.log*
13 | yarn-error.log*
14 | pnpm-debug.log*
15 |
16 | # Editor directories and files
17 | .idea
18 | .vscode
19 | *.suo
20 | *.ntvs*
21 | *.njsproj
22 | *.sln
23 | *.sw?
24 |
--------------------------------------------------------------------------------
/.husky/commit-msg:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | . "$(dirname -- "$0")/_/husky.sh"
3 |
4 | npx --no-install commitlint --edit $1
5 |
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | . "$(dirname -- "$0")/_/husky.sh"
3 |
4 | npx lint-staged
5 |
--------------------------------------------------------------------------------
/.lintstagedrc:
--------------------------------------------------------------------------------
1 | {
2 | "*.ts": [
3 | "eslint --fix"
4 | ],
5 | "*.vue": [
6 | "eslint --fix"
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | shamefully-hoist=true
2 | auto-install-peers=true
3 | strict-peer-dependencies=false
4 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4 |
5 | ### [3.0.21](https://github.com/mirari/v-viewer/compare/v3.0.20...v3.0.21) (2024-11-02)
6 |
7 |
8 | ### Bug Fixes
9 |
10 | * fix type declaration ([e16928b](https://github.com/mirari/v-viewer/commit/e16928b3badcdbc2a79f3ab2f06a7feeb0700521))
11 |
12 | ### [3.0.20](https://github.com/mirari/v-viewer/compare/v3.0.19...v3.0.20) (2024-09-26)
13 |
14 |
15 | ### Bug Fixes
16 |
17 | * fix package setting mistake ([6e54d96](https://github.com/mirari/v-viewer/commit/6e54d9643bc015710ca5eb1d971569c1f1336589))
18 |
19 | ### [3.0.19](https://github.com/mirari/v-viewer/compare/v3.0.18...v3.0.19) (2024-09-26)
20 |
21 |
22 | ### Bug Fixes
23 |
24 | * fix package setting mistake ([f930882](https://github.com/mirari/v-viewer/commit/f930882443b60bd23f62c88c0634692f9237bd5c))
25 |
26 | ### [3.0.18](https://github.com/mirari/v-viewer/compare/v3.0.17...v3.0.18) (2024-09-26)
27 |
28 |
29 | ### Bug Fixes
30 |
31 | * support iife ([02662af](https://github.com/mirari/v-viewer/commit/02662afd89f8f307a0e825fd601a710939a463d0))
32 |
33 | ### [3.0.17](https://github.com/mirari/v-viewer/compare/v3.0.16...v3.0.17) (2024-09-26)
34 |
35 |
36 | ### Bug Fixes
37 |
38 | * fix package setting mistake ([4465979](https://github.com/mirari/v-viewer/commit/4465979cc8f07d924300cc7e802f752902f637bb))
39 |
40 | ### [3.0.16](https://github.com/mirari/v-viewer/compare/v3.0.15...v3.0.16) (2024-09-26)
41 |
42 | ### [3.0.15](https://github.com/mirari/v-viewer/compare/v3.0.14...v3.0.15) (2024-09-26)
43 |
44 |
45 | ### Bug Fixes
46 |
47 | * fix the issue of incorrect entry reference caused by the unspecified type in package.json.[#338](https://github.com/mirari/v-viewer/issues/338) ([f493490](https://github.com/mirari/v-viewer/commit/f4934906d7c90c79571c7bf3edb160cc6b34e2f8))
48 |
49 | ### [3.0.14](https://github.com/mirari/v-viewer/compare/v3.0.13...v3.0.14) (2024-01-06)
50 |
51 |
52 | ### Bug Fixes
53 |
54 | * update dependencies ([e9003e0](https://github.com/mirari/v-viewer/commit/e9003e0902f7cc8c0d03d9ed9b520580c263ade7))
55 |
56 | ### [3.0.13](https://github.com/mirari/v-viewer/compare/v3.0.9...v3.0.13) (2024-01-03)
57 |
58 |
59 | ### Bug Fixes
60 |
61 | * **common:** remove unnecessary configuration to fit vite(SSR) correctly ([d8e2100](https://github.com/mirari/v-viewer/commit/d8e2100086b2058bbd8c225ddb5b990a45ea1149))
62 | * **component:** fix the problem of not updating when changing options ([1b2e3ae](https://github.com/mirari/v-viewer/commit/1b2e3ae26b947d80cbea3f4a25ea2ccf9e59b5fd)), closes [#197](https://github.com/mirari/v-viewer/issues/197)
63 | * modify util function ([d05dd3c](https://github.com/mirari/v-viewer/commit/d05dd3c0a5096e32fce2e4f020fe8775f3dfeb7c))
64 |
65 | ### [3.0.12](https://github.com/mirari/v-viewer/compare/v3.0.11...v3.0.12) (2024-01-03)
66 |
67 | ### [3.0.11](https://github.com/mirari/v-viewer/compare/v3.0.9...v3.0.11) (2022-10-25)
68 |
69 |
70 | ### Bug Fixes
71 |
72 | * **common:** remove unnecessary configuration to fit vite(SSR) correctly ([d8e2100](https://github.com/mirari/v-viewer/commit/d8e2100086b2058bbd8c225ddb5b990a45ea1149))
73 | * **component:** fix the problem of not updating when changing options ([1b2e3ae](https://github.com/mirari/v-viewer/commit/1b2e3ae26b947d80cbea3f4a25ea2ccf9e59b5fd)), closes [#197](https://github.com/mirari/v-viewer/issues/197)
74 |
75 | ### [3.0.10](https://github.com/mirari/v-viewer/compare/v3.0.9...v3.0.10) (2021-09-21)
76 |
77 |
78 | ### Bug Fixes
79 |
80 | * **component:** fix the problem of not updating when changing options ([d7afcdb](https://github.com/mirari/v-viewer/commit/d7afcdbf5d597f3971e0bea43ce36f390972e312)), closes [#197](https://github.com/mirari/v-viewer/issues/197)
81 |
82 | ### [3.0.9](https://github.com/mirari/v-viewer/compare/v3.0.8...v3.0.9) (2021-06-02)
83 |
84 |
85 | ### Bug Fixes
86 |
87 | * **common:** fix dts file ([f6163ff](https://github.com/mirari/v-viewer/commit/f6163ff5b316a940d70fb842605f220b7f378416))
88 |
89 | ### [3.0.8](https://github.com/mirari/v-viewer/compare/v3.0.7...v3.0.8) (2021-06-02)
90 |
91 | ### [3.0.7](https://github.com/mirari/v-viewer/compare/v3.0.6...v3.0.7) (2021-06-02)
92 |
93 |
94 | ### Bug Fixes
95 |
96 | * **common:** fix tsd file; update readme ([2295dcc](https://github.com/mirari/v-viewer/commit/2295dcc338dfb296f4780542c6d38921284c6c9d))
97 |
98 | ### [3.0.6](https://github.com/mirari/v-viewer/compare/v3.0.5...v3.0.6) (2021-05-31)
99 |
100 | ### 3.0.5 (2021-05-31)
101 |
102 |
103 | ### Bug Fixes
104 |
105 | * **api:** fix type declaration ([9987966](https://github.com/mirari/v-viewer/commit/9987966db12372186adc95a5b37643c9ce1587bb))
106 | * **common:** fix api option ([f54bcb2](https://github.com/mirari/v-viewer/commit/f54bcb266c4fa83492a9dfaa2e513960727b9873))
107 | * **common:** fix umd build config ([3fc6477](https://github.com/mirari/v-viewer/commit/3fc64772fc7b7271f233b239c2c26d39f16d3396))
108 | * **directive:** fix default options ([c7ffa87](https://github.com/mirari/v-viewer/commit/c7ffa87b6d9259e2f304f85467e1d5609f53e912))
109 |
110 | ### [3.0.4](https://github.com/mirari/v-viewer/compare/v3.0.3...v3.0.4) (2021-05-30)
111 |
112 |
113 | ### Bug Fixes
114 |
115 | * **api:** fix type declaration ([9987966](https://github.com/mirari/v-viewer/commit/9987966db12372186adc95a5b37643c9ce1587bb))
116 |
117 | ### [3.0.3](https://github.com/mirari/v-viewer/compare/v3.0.2...v3.0.3) (2021-05-30)
118 |
119 | ### [3.0.2](https://github.com/mirari/v-viewer/compare/v3.0.1...v3.0.2) (2021-05-30)
120 |
121 |
122 | ### Bug Fixes
123 |
124 | * **common:** fix api option ([f54bcb2](https://github.com/mirari/v-viewer/commit/f54bcb266c4fa83492a9dfaa2e513960727b9873))
125 |
126 | ### [3.0.1](https://github.com/mirari/v-viewer/compare/v3.0.0...v3.0.1) (2021-05-30)
127 |
128 |
129 | ### Bug Fixes
130 |
131 | * **common:** fix umd build config ([3fc6477](https://github.com/mirari/v-viewer/commit/3fc64772fc7b7271f233b239c2c26d39f16d3396))
132 |
133 | ## 3.0.0 (2021-05-30)
134 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 mirari
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # v-viewer
2 |
3 | Image viewer component for vue, supports rotation, scale, zoom and so on, based on [viewer.js](https://github.com/fengyuanchen/viewerjs)
4 |
5 | [](https://www.npmjs.com/package/v-viewer)
6 | [](https://www.npmjs.com/package/v-viewer)
7 |
8 | [](https://www.npmjs.com/package/v-viewer)
9 | [](https://www.npmjs.com/package/v-viewer)
10 |
11 | [](https://www.npmjs.com/package/v-viewer)
12 | [](https://mit-license.org/)
13 |
14 | ## [v-viewer for vue2](https://github.com/mirari/v-viewer/tree/v2)
15 |
16 | ## [Live demo](https://mirari.github.io/vue3-viewer/)
17 |
18 | ## Quick Example
19 |
20 | - [directive](https://codepen.io/mirari/pen/yLMPPWy)
21 | - [component](https://codepen.io/mirari/pen/ZEeaaWZ)
22 | - [api](https://codepen.io/mirari/pen/qBrVpNV)
23 | - [thumbnail & source](https://codepen.io/mirari/pen/Vwpryax)
24 | - [viewer callback](https://codepen.io/mirari/pen/eYveypz)
25 | - [custom toolbar](https://codepen.io/mirari/pen/ZEXqyPq)
26 | - [filter images](https://codepen.io/mirari/pen/mdWqpwa)
27 | - [change images](https://codepen.io/mirari/pen/ExWbovw)
28 |
29 | ## [中文文档](https://mirari.cc/posts/vue3-viewer)
30 |
31 | ## Installation
32 |
33 | Install from NPM
34 |
35 | ```bash
36 | npm install v-viewer viewerjs
37 | ```
38 |
39 | ## Usage
40 |
41 | To use `v-viewer`, simply import it and the `css` file, and call `app.use()` to install.
42 |
43 | The component, directive and api will be installed together in the global.
44 |
45 | Two different API styles are both supported: **Options API** and **Composition API**.
46 |
47 | ```ts
48 | import { createApp } from 'vue'
49 | import App from './App.vue'
50 | import 'viewerjs/dist/viewer.css'
51 | import VueViewer from 'v-viewer'
52 | const app = createApp(App)
53 | app.use(VueViewer)
54 | app.mount('#app')
55 | ```
56 |
57 | ```vue
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
94 |
95 |
108 | ```
109 |
110 | ### Support UMD
111 |
112 | #### Browser
113 |
114 | ```html
115 |
116 |
117 |
118 |
119 |
122 | ```
123 |
124 | #### CommonJS
125 |
126 | ```javascript
127 | var VueViewer = require('VueViewer')
128 | ```
129 |
130 | #### AMD
131 |
132 | ```javascript
133 | require(['VueViewer'], function (VueViewer) {});
134 | ```
135 |
136 | ### Usage of directive
137 |
138 | Just add the directive `v-viewer` to any element, then all `img` elements in it will be handled by `viewer`.
139 |
140 | You can set the options like this: `v-viewer="{inline: true}"`
141 |
142 | Get the element by selector and then use `el.$viewer` to get the `viewer` instance if you need.
143 |
144 | ```vue
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
181 |
182 |
198 | ```
199 |
200 | #### Directive modifiers
201 |
202 | ##### static
203 |
204 | The `viewer` instance will be created only once after the directive binded.
205 |
206 | If you're sure the images inside this element won't change again, use it to avoid unnecessary re-render.
207 |
208 | ```vue
209 |
210 |
211 |
212 | ```
213 |
214 | ##### rebuild
215 |
216 | The `viewer` instance will be updated by `update` method when the source images changed (added, removed or sorted) by default.
217 |
218 | If you encounter any display problems, try rebuilding instead of updating.
219 |
220 | ```vue
221 |
222 |
223 |
224 | ```
225 |
226 | ### Usage of component
227 |
228 | You can simply import the component and register it locally too.
229 |
230 | ```vue
231 |
232 |