impetus icon indicating copy to clipboard operation
impetus copied to clipboard

How to judge whether the exercise has stopped

Open swimly opened this issue 4 years ago • 0 comments

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)`
      }
    })

swimly avatar May 14 '20 10:05 swimly