feat(Swipe): some props can be string

This commit is contained in:
陈嘉涵 2020-01-31 10:15:34 +08:00
parent 526202cc40
commit 5e658b08ce
5 changed files with 16 additions and 16 deletions

View File

@ -196,8 +196,8 @@ In scrollspy mode, the list of content will be tiled
| v-model | Index of active tab | *number \| string* | `0` |
| type | Can be set to `line` `card` | *string* | `line` |
| color | Tab color | *string* | `#ee0a24` |
| duration | Toggle tab's animation time | *number* | `0.3` | - |
| background | Background color | *string* | `white` |
| duration | Toggle tab's animation time | *number \| string* | `0.3` | - |
| line-width | Width of tab line | *number \| string* | Width of active tab |
| line-height | Height of tab line | *number \| string* | `3px` |
| animated | Whether to change tabs with animation | *boolean* | `false` |
@ -207,8 +207,8 @@ In scrollspy mode, the list of content will be tiled
| swipeable | Whether to switch tabs with swipe gestrue in the content | *boolean* | `false` |
| lazy-render | Whether to enable tab content lazy render | *boolean* | `true` |
| scrollspy `v2.3.0` | Whether to use scrollspy mode | *boolean* | `false` |
| offset-top | Offset top when use sticky mode | *number* | `0` |
| swipe-threshold | Set swipe tabs threshold | *number* | `4` | - |
| offset-top | Offset top when use sticky mode | *number \| string* | `0` |
| swipe-threshold | Set swipe tabs threshold | *number \| string* | `4` | - |
| title-active-color | Title active color | *string* | - |
| title-inactive-color | Title inactive color | *string* | - |

View File

@ -200,10 +200,10 @@ export default {
| v-model | 绑定当前选中标签的标识符 | *number \| string* | `0` |
| type | 样式风格类型,可选值为`card` | *string* | `line` |
| color | 标签主题色 | *string* | `#ee0a24` |
| duration | 动画时间,单位秒 | *number* | `0.3` |
| background | 标签栏背景色 | *string* | `white` |
| line-width | 底部条宽度,默认单位 px | *number \| string* | `auto` |
| line-height | 底部条高度,默认单位 px | *number \| string* | `3px` |
| duration | 动画时间,单位秒 | *number \| string* | `0.3` |
| line-width | 底部条宽度,默认单位`px` | *number \| string* | `auto` |
| line-height | 底部条高度,默认单位`px` | *number \| string* | `3px` |
| animated | 是否开启切换标签内容时的转场动画 | *boolean* | `false` |
| border | 是否显示标签栏外边框,仅在`type="line"`时有效 | *boolean* | `true` |
| ellipsis | 是否省略过长的标题文字 | *boolean* | `true` |
@ -211,8 +211,8 @@ export default {
| swipeable | 是否开启手势滑动切换 | *boolean* | `false` |
| lazy-render | 是否开启延迟渲染(首次切换到标签时才触发内容渲染) | *boolean* | `true` |
| scrollspy `v2.3.0` | 是否开启滚动导航 | *boolean* | `false` |
| offset-top | 粘性定位布局下与顶部的最小距离,单位 px | *number* | `0` |
| swipe-threshold | 滚动阈值,标签数量超过阈值时开始横向滚动 | *number* | `4` |
| offset-top | 粘性定位布局下与顶部的最小距离,单位`px` | *number \| string* | `0` |
| swipe-threshold | 滚动阈值,标签数量超过阈值时开始横向滚动 | *number \| string* | `4` |
| title-active-color | 标题选中态颜色 | *string* | - |
| title-inactive-color | 标题默认态颜色 | *string* | - |

View File

@ -9,7 +9,7 @@ export default createComponent({
props: {
count: Number,
duration: Number,
duration: [Number, String],
animated: Boolean,
swipeable: Boolean,
currentIndex: Number,

View File

@ -16,7 +16,7 @@ export default createComponent({
scrollable: Boolean,
activeColor: String,
inactiveColor: String,
swipeThreshold: Number,
swipeThreshold: [Number, String],
},
computed: {

View File

@ -66,11 +66,11 @@ export default createComponent({
default: true,
},
duration: {
type: Number,
type: [Number, String],
default: 0.3,
},
offsetTop: {
type: Number,
type: [Number, String],
default: 0,
},
lazyRender: {
@ -78,7 +78,7 @@ export default createComponent({
default: true,
},
swipeThreshold: {
type: Number,
type: [Number, String],
default: 4,
},
},
@ -116,7 +116,7 @@ export default createComponent({
scrollOffset() {
if (this.sticky) {
return this.offsetTop + this.tabHeight;
return +this.offsetTop + this.tabHeight;
}
return 0;
},
@ -284,7 +284,7 @@ export default createComponent({
const title = titles[this.currentIndex].$el;
const to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
scrollLeftTo(nav, to, immediate ? 0 : this.duration);
scrollLeftTo(nav, to, immediate ? 0 : +this.duration);
},
onSticktScroll(params) {
@ -299,7 +299,7 @@ export default createComponent({
const el = instance && instance.$el;
if (el) {
const to = Math.ceil(getElementTop(el)) - this.scrollOffset;
scrollTopTo(to, this.duration, () => {
scrollTopTo(to, +this.duration, () => {
this.clickedScroll = false;
});
}