|
| 1 | +# vue-active-swiper |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +    |
| 6 | + |
| 7 | +`vue-active-preview` is a Mobile-oriented、No dependencies、Lightweight PhotoSwipe Component(`image gallery`) for Vue. |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +[简体中文](https://github.com/accforgit/vue-active-preview/blob/master/README.md) | English |
| 12 | + |
| 13 | +## Example |
| 14 | + |
| 15 | +- [Live Demo](https://accforgit.github.io/vue-active-preview/basic.html) |
| 16 | + |
| 17 | +## Install |
| 18 | + |
| 19 | +``` |
| 20 | +npm install vue-active-preview --save |
| 21 | +``` |
| 22 | + |
| 23 | +## Import |
| 24 | + |
| 25 | +### import with global |
| 26 | + |
| 27 | +```js |
| 28 | +// require styles |
| 29 | +import 'vue-active-preview/dist/VueActivePreview.css' |
| 30 | + |
| 31 | +import Vue from 'vue' |
| 32 | +import VueActivePreview from 'vue-active-preview' |
| 33 | + |
| 34 | +Vue.use(VueActivePreview) |
| 35 | +``` |
| 36 | + |
| 37 | +### import with component |
| 38 | + |
| 39 | +```js |
| 40 | +// require styles |
| 41 | +import 'vue-active-preview/dist/VueActivePreview.css' |
| 42 | + |
| 43 | +// in ES6 modules |
| 44 | +import VueActivePreview from 'vue-active-preview' |
| 45 | + |
| 46 | +// in CommonJS |
| 47 | +const VueActivePreview = require('vue-active-preview') |
| 48 | + |
| 49 | +export default { |
| 50 | + components: { |
| 51 | + VueActivePreview |
| 52 | + } |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +### import with script |
| 57 | + |
| 58 | +```html |
| 59 | +<link rel="stylesheet" href="../node-modules/vue-active-preview/dist/VueActivePreview.css" charset="utf-8"> |
| 60 | +<script src="../node-modules/vue-active-preview/dist/VueActivePreview.umd.min.js"></script> |
| 61 | +``` |
| 62 | + |
| 63 | +```js |
| 64 | +new Vue({ |
| 65 | + el: '#app', |
| 66 | + components: { |
| 67 | + VueActivePreview |
| 68 | + } |
| 69 | +}) |
| 70 | +``` |
| 71 | + |
| 72 | +## Usage |
| 73 | + |
| 74 | +Work on a Vue instance: |
| 75 | +```html |
| 76 | +<VueActivePreview :urlList="[ |
| 77 | + 'https://dummyimage.com/375x100/FB8A80?text=1', |
| 78 | + 'https://dummyimage.com/375x100/29A90F?text=2', |
| 79 | + 'https://dummyimage.com/375x100/6F9DFF?text=3' |
| 80 | +]" /> |
| 81 | +``` |
| 82 | + |
| 83 | +## Props |
| 84 | + |
| 85 | +|Option|Type|Description|Default|necessary| |
| 86 | +|----|---|----|----|---| |
| 87 | +|urlList|Array|image array|[]|false| |
| 88 | +|backgroundSize|String|Specifies how the image is scaled in the sliding-container-box,Value and Effect are the same as `CSS background-size`|contain|false| |
| 89 | +|maxScaleValue|Number|Maximum magnification,if the value is 0,then no limit|5|false| |
| 90 | +|showCounter|Boolean|if need a default counter|false|false| |
| 91 | +|counterStyle|Object|Customize the style of the default counter <br>Valid only when `showCounter` is `true`|null|false| |
| 92 | +|startIndex|Number|Start preview item index|0|false| |
| 93 | +|criticalValue|Number|Proportional value of critical point <br>When it exceeds the critical point represented by this value, it will automatically slide to the next picture.|1/3|false| |
| 94 | +|autoPlayDelay|Number|If this parameter is specified and the value `>= 0`, the value will be taken as the time of automatic rotation `delay`(`ms`) for automatic rotation;Non-designated non-automatic rotation <br>If you want to specify this value, it is generally recommended to set it to `3000`|null|false| |
| 95 | +|duration|Number|The time(`ms`) required to automatically scroll to a stable position|350|false| |
| 96 | +|noDragWhenSingle|Boolean|If there is only one `swipeItem`, is dragging prohibited|true|false| |
| 97 | +|changeCallback|Function|Callback after each scroll,Callback parameter is current `activeIndex`|-|false| |
| 98 | + |
| 99 | +## Extra |
| 100 | + |
| 101 | +### slot |
| 102 | + |
| 103 | +`Swiper` can also receive a slot,make it easier for developers to customize components more freely: |
| 104 | +```html |
| 105 | +<VueActivePreview :urlList="urlList"> |
| 106 | + <p>slot content</p> |
| 107 | +</VueActivePreview> |
| 108 | +``` |
| 109 | + |
| 110 | +## License |
| 111 | + |
| 112 | +MIT |
0 commit comments