mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[new feature] ImagePreview: add swipe-duration prop (#3963)
This commit is contained in:
parent
dc0e71556b
commit
f52890cfd6
@ -38,6 +38,10 @@ export default createComponent({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
|
swipeDuration: {
|
||||||
|
type: Number,
|
||||||
|
default: 500
|
||||||
|
},
|
||||||
overlay: {
|
overlay: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: true
|
||||||
@ -267,6 +271,7 @@ export default createComponent({
|
|||||||
<Swipe
|
<Swipe
|
||||||
ref="swipe"
|
ref="swipe"
|
||||||
loop={this.loop}
|
loop={this.loop}
|
||||||
|
duration={this.swipeDuration}
|
||||||
indicatorColor="white"
|
indicatorColor="white"
|
||||||
initialSwipe={this.startPosition}
|
initialSwipe={this.startPosition}
|
||||||
showIndicators={this.showIndicators}
|
showIndicators={this.showIndicators}
|
||||||
|
@ -94,6 +94,7 @@ export default {
|
|||||||
| showIndex | Whether to show index | `boolean` | `true` |
|
| showIndex | Whether to show index | `boolean` | `true` |
|
||||||
| showIndicators | Whether to show indicators | `boolean` | `false` |
|
| showIndicators | Whether to show indicators | `boolean` | `false` |
|
||||||
| loop | Whether to enable loop | `boolean` | `true` |
|
| loop | Whether to enable loop | `boolean` | `true` |
|
||||||
|
| swipeDuration | Animation duration (ms) | `number` | `500` |
|
||||||
| onClose | Triggered when close | `Function` | - |
|
| onClose | Triggered when close | `Function` | - |
|
||||||
| onChange | Triggered when current image change | `Function` | - |
|
| onChange | Triggered when current image change | `Function` | - |
|
||||||
| closeOnPopstate | Whether to close when popstate | `boolean` | `false` |
|
| closeOnPopstate | Whether to close when popstate | `boolean` | `false` |
|
||||||
@ -112,6 +113,7 @@ export default {
|
|||||||
| show-index | Whether to show index | `boolean` | `true` |
|
| show-index | Whether to show index | `boolean` | `true` |
|
||||||
| show-indicators | Whether to show indicators | `boolean` | `false` |
|
| show-indicators | Whether to show indicators | `boolean` | `false` |
|
||||||
| loop | Whether to enable loop | `boolean` | `true` |
|
| loop | Whether to enable loop | `boolean` | `true` |
|
||||||
|
| swipe-duration | Animation duration (ms) | `number` | `500` |
|
||||||
| async-close | Whether to enable async close | `boolean` | `false` |
|
| async-close | Whether to enable async close | `boolean` | `false` |
|
||||||
| close-on-popstate | Whether to close when popstate | `boolean` | `false` |
|
| close-on-popstate | Whether to close when popstate | `boolean` | `false` |
|
||||||
| class-name | Custom className | `any` | - |
|
| class-name | Custom className | `any` | - |
|
||||||
|
@ -106,6 +106,7 @@ export default {
|
|||||||
| showIndex | 是否显示页码 | `boolean` | `true` | - |
|
| showIndex | 是否显示页码 | `boolean` | `true` | - |
|
||||||
| showIndicators | 是否显示轮播指示器 | `boolean` | `false` | - |
|
| showIndicators | 是否显示轮播指示器 | `boolean` | `false` | - |
|
||||||
| loop | 是否开启循环播放 | `boolean` | `true` | - |
|
| loop | 是否开启循环播放 | `boolean` | `true` | - |
|
||||||
|
| swipeDuration | 动画时长,单位为 ms | `number` | `500` | - |
|
||||||
| onClose | 关闭时的回调函数 | `Function` | - | - |
|
| onClose | 关闭时的回调函数 | `Function` | - | - |
|
||||||
| onChange | 切换图片时的回调函数,回调参数为当前索引 | `Function` | - | 2.0.3 |
|
| onChange | 切换图片时的回调函数,回调参数为当前索引 | `Function` | - | 2.0.3 |
|
||||||
| asyncClose | 是否开启异步关闭 | `boolean` | `false` | - |
|
| asyncClose | 是否开启异步关闭 | `boolean` | `false` | - |
|
||||||
@ -126,6 +127,7 @@ export default {
|
|||||||
| show-index | 是否显示页码 | `boolean` | `true` | 1.3.4 |
|
| show-index | 是否显示页码 | `boolean` | `true` | 1.3.4 |
|
||||||
| show-indicators | 是否显示轮播指示器 | `boolean` | `false` | 1.3.10 |
|
| show-indicators | 是否显示轮播指示器 | `boolean` | `false` | 1.3.10 |
|
||||||
| loop | 是否开启循环播放 | `boolean` | `true` | 1.4.4 |
|
| loop | 是否开启循环播放 | `boolean` | `true` | 1.4.4 |
|
||||||
|
| swipe-duration | 动画时长,单位为 ms | `number` | `500` | - |
|
||||||
| async-close | 是否开启异步关闭 | `boolean` | `false` | 1.4.8 |
|
| async-close | 是否开启异步关闭 | `boolean` | `false` | 1.4.8 |
|
||||||
| close-on-popstate | 是否在页面回退时自动关闭 | `boolean` | `false` |
|
| close-on-popstate | 是否在页面回退时自动关闭 | `boolean` | `false` |
|
||||||
| class-name | 自定义类名 | `any` | - | 1.5.2 |
|
| class-name | 自定义类名 | `any` | - | 1.5.2 |
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
<van-image-preview
|
<van-image-preview
|
||||||
v-model="show"
|
v-model="show"
|
||||||
:images="images"
|
:images="images"
|
||||||
|
:swipe-duration="300"
|
||||||
@change="onChange"
|
@change="onChange"
|
||||||
>
|
>
|
||||||
<template #index>{{ $t('index', index) }}</template>
|
<template #index>{{ $t('index', index) }}</template>
|
||||||
@ -93,6 +94,7 @@ export default {
|
|||||||
showImagePreview(position, timer) {
|
showImagePreview(position, timer) {
|
||||||
const instance = ImagePreview({
|
const instance = ImagePreview({
|
||||||
images,
|
images,
|
||||||
|
swipeDuration: 300,
|
||||||
asyncClose: !!timer,
|
asyncClose: !!timer,
|
||||||
closeOnPopstate: true,
|
closeOnPopstate: true,
|
||||||
startPosition: typeof position === 'number' ? position : 0
|
startPosition: typeof position === 'number' ? position : 0
|
||||||
|
@ -7,6 +7,7 @@ let instance;
|
|||||||
const defaultConfig = {
|
const defaultConfig = {
|
||||||
images: [],
|
images: [],
|
||||||
loop: true,
|
loop: true,
|
||||||
|
swipeDuration: 500,
|
||||||
value: true,
|
value: true,
|
||||||
minZoom: 1 / 3,
|
minZoom: 1 / 3,
|
||||||
maxZoom: 3,
|
maxZoom: 3,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user