mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Swipe): some props can be string
This commit is contained in:
parent
21a0d4e877
commit
e9f96393f9
@ -148,17 +148,17 @@ export default {
|
|||||||
|
|
||||||
| Attribute | Description | Type | Default |
|
| Attribute | Description | Type | Default |
|
||||||
|------|------|------|------|
|
|------|------|------|------|
|
||||||
| autoplay | Autoplay interval (ms) | *number* | - |
|
| autoplay | Autoplay interval (ms) | *number \| string* | - |
|
||||||
| duration | Animation duration (ms) | *number* | `500` |
|
| duration | Animation duration (ms) | *number \| string* | `500` |
|
||||||
| initial-swipe | Index of initial swipe, start from 0 | *number* | `0` |
|
| initial-swipe | Index of initial swipe, start from 0 | *number \| string* | `0` |
|
||||||
| width | Set Swiper Item Width | *number* | `0` |
|
| width | Set Swiper Item Width | *number \| string* | `0` |
|
||||||
| height | Set Swiper Item Height | *number* | `0` |
|
| height | Set Swiper Item Height | *number \| string* | `0` |
|
||||||
| loop | Whether to enable loop | *boolean* | `true` |
|
| loop | Whether to enable loop | *boolean* | `true` |
|
||||||
| show-indicators | Whether to show indicators | *boolean* | `true` |
|
| show-indicators | Whether to show indicators | *boolean* | `true` |
|
||||||
| indicator-color | Indicator color | *string* | `#1989fa` |
|
|
||||||
| vertical | Whether to be vertical Scrolling | *boolean* | `false` |
|
| vertical | Whether to be vertical Scrolling | *boolean* | `false` |
|
||||||
| touchable | Whether to allow swipe by touch gesture | *boolean* | `true` |
|
| touchable | Whether to allow swipe by touch gesture | *boolean* | `true` |
|
||||||
| stop-propagation `v2.1.0` | Whether to stop touchmove event propagation | *boolean* | `false` |
|
| stop-propagation `v2.1.0` | Whether to stop touchmove event propagation | *boolean* | `false` |
|
||||||
|
| indicator-color | Indicator color | *string* | `#1989fa` |
|
||||||
|
|
||||||
### Swipe Events
|
### Swipe Events
|
||||||
|
|
||||||
|
@ -154,17 +154,17 @@ export default {
|
|||||||
|
|
||||||
| 参数 | 说明 | 类型 | 默认值 |
|
| 参数 | 说明 | 类型 | 默认值 |
|
||||||
|------|------|------|------|
|
|------|------|------|------|
|
||||||
| autoplay | 自动轮播间隔,单位为 ms | *number* | - |
|
| autoplay | 自动轮播间隔,单位为 ms | *number \| string* | - |
|
||||||
| duration | 动画时长,单位为 ms | *number* | `500` |
|
| duration | 动画时长,单位为 ms | *number \| string* | `500` |
|
||||||
| initial-swipe | 初始位置索引值 | *number* | `0` |
|
| initial-swipe | 初始位置索引值 | *number \| string* | `0` |
|
||||||
| width | 滑块宽度 | *number* | `auto` |
|
| width | 滑块宽度,单位为`px` | *number \| string* | `auto` |
|
||||||
| height | 滑块高度 | *number* | `auto` |
|
| height | 滑块高度,单位为`px` | *number \| string* | `auto` |
|
||||||
| loop | 是否开启循环播放 | *boolean* | `true` |
|
| loop | 是否开启循环播放 | *boolean* | `true` |
|
||||||
| show-indicators | 是否显示指示器 | *boolean* | `true` |
|
| show-indicators | 是否显示指示器 | *boolean* | `true` |
|
||||||
| indicator-color | 指示器颜色 | *string* | `#1989fa` |
|
|
||||||
| vertical | 是否为纵向滚动 | *boolean* | `false` |
|
| vertical | 是否为纵向滚动 | *boolean* | `false` |
|
||||||
| touchable | 是否可以通过手势滑动 | *boolean* | `true` |
|
| touchable | 是否可以通过手势滑动 | *boolean* | `true` |
|
||||||
| stop-propagation `v2.2.13` | 是否阻止滑动事件冒泡 | *boolean* | `true` |
|
| stop-propagation `v2.2.13` | 是否阻止滑动事件冒泡 | *boolean* | `true` |
|
||||||
|
| indicator-color | 指示器颜色 | *string* | `#1989fa` |
|
||||||
|
|
||||||
### Swipe Events
|
### Swipe Events
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@ export default createComponent({
|
|||||||
],
|
],
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
width: Number,
|
width: [Number, String],
|
||||||
height: Number,
|
height: [Number, String],
|
||||||
autoplay: Number,
|
autoplay: [Number, String],
|
||||||
vertical: Boolean,
|
vertical: Boolean,
|
||||||
indicatorColor: String,
|
indicatorColor: String,
|
||||||
loop: {
|
loop: {
|
||||||
@ -36,7 +36,7 @@ export default createComponent({
|
|||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
duration: {
|
duration: {
|
||||||
type: Number,
|
type: [Number, String],
|
||||||
default: 500,
|
default: 500,
|
||||||
},
|
},
|
||||||
touchable: {
|
touchable: {
|
||||||
@ -44,7 +44,7 @@ export default createComponent({
|
|||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
initialSwipe: {
|
initialSwipe: {
|
||||||
type: Number,
|
type: [Number, String],
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
showIndicators: {
|
showIndicators: {
|
||||||
@ -80,10 +80,10 @@ export default createComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
autoplay(autoplay) {
|
autoplay(autoplay) {
|
||||||
if (!autoplay) {
|
if (autoplay > 0) {
|
||||||
this.clear();
|
|
||||||
} else {
|
|
||||||
this.autoPlay();
|
this.autoPlay();
|
||||||
|
} else {
|
||||||
|
this.clear();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -146,13 +146,13 @@ export default createComponent({
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
// initialize swipe position
|
// initialize swipe position
|
||||||
initialize(active = this.initialSwipe) {
|
initialize(active = +this.initialSwipe) {
|
||||||
clearTimeout(this.timer);
|
clearTimeout(this.timer);
|
||||||
|
|
||||||
if (this.$el) {
|
if (this.$el) {
|
||||||
const rect = this.$el.getBoundingClientRect();
|
const rect = this.$el.getBoundingClientRect();
|
||||||
this.computedWidth = this.width || rect.width;
|
this.computedWidth = +this.width || rect.width;
|
||||||
this.computedHeight = this.height || rect.height;
|
this.computedHeight = +this.height || rect.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.swiping = true;
|
this.swiping = true;
|
||||||
@ -345,7 +345,7 @@ export default createComponent({
|
|||||||
autoPlay() {
|
autoPlay() {
|
||||||
const { autoplay } = this;
|
const { autoplay } = this;
|
||||||
|
|
||||||
if (autoplay && this.count > 1) {
|
if (autoplay > 0 && this.count > 1) {
|
||||||
this.clear();
|
this.clear();
|
||||||
this.timer = setTimeout(() => {
|
this.timer = setTimeout(() => {
|
||||||
this.next();
|
this.next();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user