|
|
@@ -29,19 +29,23 @@ export default {
|
|
|
props: {
|
|
|
listData: {
|
|
|
type: Array,
|
|
|
- required: true
|
|
|
+ required: true,
|
|
|
},
|
|
|
defaultValue: {
|
|
|
- type: String | Number
|
|
|
+ type: String | Number,
|
|
|
},
|
|
|
keyIndex: {
|
|
|
type: Number,
|
|
|
- default: 0
|
|
|
+ default: 0,
|
|
|
},
|
|
|
isUpdate: {
|
|
|
type: Boolean,
|
|
|
- default: false
|
|
|
- }
|
|
|
+ default: false,
|
|
|
+ },
|
|
|
+ swipeDuration: {
|
|
|
+ type: Number | String,
|
|
|
+ default: '1000',
|
|
|
+ },
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -49,25 +53,25 @@ export default {
|
|
|
startY: 0,
|
|
|
endY: 0,
|
|
|
startTime: 0,
|
|
|
- endTime: 0
|
|
|
+ endTime: 0,
|
|
|
},
|
|
|
currIndex: 1,
|
|
|
transformY: 0,
|
|
|
scrollDistance: 0,
|
|
|
lineSpacing: 36,
|
|
|
rotation: 20,
|
|
|
- timer: null
|
|
|
+ timer: null,
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
|
- isUpdate: function() {
|
|
|
+ isUpdate: function () {
|
|
|
this.transformY = 0;
|
|
|
this.modifyStatus();
|
|
|
},
|
|
|
- defaultValue: function() {
|
|
|
+ defaultValue: function () {
|
|
|
this.transformY = 0;
|
|
|
this.modifyStatus();
|
|
|
- }
|
|
|
+ },
|
|
|
},
|
|
|
methods: {
|
|
|
updateTransform(value) {
|
|
|
@@ -172,8 +176,7 @@ export default {
|
|
|
let moveTime = this.touchParams.lastTime - this.touchParams.startTime;
|
|
|
if (moveTime <= 300) {
|
|
|
move = move * 2;
|
|
|
- moveTime = moveTime + 1000;
|
|
|
- this.setMove(move, 'end', moveTime);
|
|
|
+ this.setMove(move, 'end', +this.swipeDuration);
|
|
|
} else {
|
|
|
this.setMove(move, 'end');
|
|
|
}
|
|
|
@@ -196,7 +199,7 @@ export default {
|
|
|
let move = index === -1 ? 0 : index * this.lineSpacing;
|
|
|
type && this.setChooseValue(-move);
|
|
|
this.setMove(-move);
|
|
|
- }
|
|
|
+ },
|
|
|
},
|
|
|
|
|
|
mounted() {
|
|
|
@@ -214,6 +217,6 @@ export default {
|
|
|
this.$el.removeEventListener('touchmove', this.touchMove);
|
|
|
this.$el.removeEventListener('touchend', this.touchEnd);
|
|
|
clearTimeout(this.timer);
|
|
|
- }
|
|
|
+ },
|
|
|
};
|
|
|
</script>
|