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
+1 -1
View File
@@ -9,7 +9,7 @@ export default createComponent({
props: {
count: Number,
duration: Number,
duration: [Number, String],
animated: Boolean,
swipeable: Boolean,
currentIndex: Number,
+1 -1
View File
@@ -16,7 +16,7 @@ export default createComponent({
scrollable: Boolean,
activeColor: String,
inactiveColor: String,
swipeThreshold: Number,
swipeThreshold: [Number, String],
},
computed: {
+6 -6
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;
});
}