[new feature] Slider: add drag-start、drag-end event

This commit is contained in:
陈嘉涵
2019-05-27 20:34:11 +08:00
parent b02773a455
commit d2a6a692c5
5 changed files with 47 additions and 8 deletions
+26 -7
View File
@@ -1,4 +1,4 @@
import { use } from '../utils';
import { use, isDef } from '../utils';
import { TouchMixin } from '../mixins/touch';
import { preventDefault } from '../utils/event';
@@ -30,17 +30,26 @@ export default sfc({
methods: {
onTouchStart(event) {
if (this.disabled) return;
if (this.disabled) {
return;
}
this.touchStart(event);
this.startValue = this.format(this.value);
this.dragStatus = 'start';
},
onTouchMove(event) {
if (this.disabled) {
return;
}
if (this.dragStatus === 'start') {
this.dragStatus = 'draging';
this.$emit('drag-start');
}
preventDefault(event, true);
if (this.disabled) return;
this.touchMove(event);
const rect = this.$el.getBoundingClientRect();
@@ -53,8 +62,18 @@ export default sfc({
},
onTouchEnd() {
if (this.disabled) return;
this.updateValue(this.newValue, true);
if (this.disabled) {
return;
}
if (isDef(this.newValue)) {
this.updateValue(this.newValue, true);
}
if (this.dragStatus === 'draging') {
this.$emit('drag-end');
this.dragStatus = '';
}
},
onClick(event) {