[improvement] Picker: stop momentum before emit confim event (#3411)

This commit is contained in:
流采
2019-05-31 09:30:56 +08:00
committed by neverland
parent e8daae912a
commit ba6dbcd673
8 changed files with 75 additions and 69 deletions

View File

@@ -129,13 +129,7 @@ export default sfc({
},
onTransitionEnd() {
this.moving = false;
if (this.transitionEndTrigger) {
this.duration = DEFAULT_DURATION;
this.transitionEndTrigger();
this.transitionEndTrigger = null;
}
this.stopMomentum();
},
onClickItem(index) {
@@ -213,6 +207,16 @@ export default sfc({
this.duration = MOMENTUM_DURATION;
this.setIndex(index, true);
},
stopMomentum() {
this.moving = false;
this.duration = 0;
if (this.transitionEndTrigger) {
this.transitionEndTrigger();
this.transitionEndTrigger = null;
}
}
},
render(h) {
@@ -223,6 +227,7 @@ export default sfc({
const wrapperStyle = {
transform: `translate3d(0, ${this.offset + baseOffset}px, 0)`,
transitionDuration: `${this.duration}ms`,
transitionProperty: this.duration ? 'transform' : 'none',
lineHeight: `${itemHeight}px`
};