Skip to content

Commit

Permalink
fix: 划出边界处理
Browse files Browse the repository at this point in the history
  • Loading branch information
Dengzygx committed Sep 8, 2020
1 parent 10cdeab commit 5ae44be
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/picker/picker-column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,17 @@ export class PickerColumn extends preact.Component<PickerProps, PickerState> {
const distance = this.state.offset - this.momentumOffset;
const duration = Date.now() - this.touchStartTime;
const allowMomentum = duration < MOMENTUM_LIMIT_TIME && Math.abs(distance) > MOMENTUM_LIMIT_DISTANCE;

if (allowMomentum) {
this.momentum(distance, duration);
return;
}

this.setState({
duration: DEFAULT_DURATION,
});

// 划出边界处理
const index = this.getIndexByOffset(this.state.offset);
this.setIndex(index);
// compatible with desktop scenario
// use setTimeout to skip the click event triggered after touchstart
setTimeout(() => {
Expand Down

0 comments on commit 5ae44be

Please sign in to comment.