fix(picker): pick correct option at low velocities (#19660)

fixes #19659
This commit is contained in:
Andreas Greimel
2020-01-09 19:35:01 +01:00
committed by Liam DeBeasi
parent cf287fda7f
commit 39d12629db

View File

@ -313,6 +313,18 @@ export class PickerColumnCmp implements ComponentInterface {
} else { } else {
this.y += detail.deltaY; this.y += detail.deltaY;
if (Math.abs(detail.velocityY) < 0.05) {
const isScrollingUp = detail.deltaY > 0;
const optHeightFraction = (Math.abs(this.y) % this.optHeight) / this.optHeight;
if (isScrollingUp && optHeightFraction > 0.5) {
this.velocity = Math.abs(this.velocity) * -1;
} else if (!isScrollingUp && optHeightFraction <= 0.5) {
this.velocity = Math.abs(this.velocity);
}
}
this.decelerate(); this.decelerate();
} }
} }