impetus
impetus copied to clipboard
How to judge whether the exercise has stopped
When I want to make a picker component, I want to adjust the displacement properly at the end of the movement. Is there any solution?
var max = this.$wrap.offsetHeight - this.itemHeight;
var offset = 0
new Impetus({
source: this.el,
boundY: [-max, 0],
multiplier: 1,
initialValues: [0, -this.current * this.itemHeight],
update: (x, y) => {
var dis = this.baseOffset() + y
offset = this.getIndexByOffset(y)
this.offset = dis
this.$wrap.style.transform = `translate3d(0, ${dis}px, 0)`
}
})