How to use the @better-scroll/shared-utils.cancelAnimationFrame function in @better-scroll/shared-utils

To help you get started, we’ve selected a few @better-scroll/shared-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ustbhuangyi / better-scroll / packages / core / src / animater / Transition.ts View on Github external
startProbe() {
    const probe = () => {
      let pos = this.translater.getComputedPosition()
      this.hooks.trigger(this.hooks.eventTypes.move, pos)
      // excute when transition ends
      if (!this.pending) {
        this.hooks.trigger(this.hooks.eventTypes.end, pos)
        return
      }
      this.timer = requestAnimationFrame(probe)
    }
    cancelAnimationFrame(this.timer)
    this.timer = requestAnimationFrame(probe)
  }
github ustbhuangyi / better-scroll / packages / core / src / animater / Transition.ts View on Github external
stop() {
    // still in transition
    if (this.pending) {
      this.setPending(false)
      cancelAnimationFrame(this.timer)
      const { x, y } = this.translater.getComputedPosition()
      this.transitionTime()
      this.translate({ x, y })
      this.setForceStopped(true)

      if (this.hooks.trigger(this.hooks.eventTypes.beforeForceStop, { x, y })) {
        return
      }

      this.hooks.trigger(this.hooks.eventTypes.forceStop, { x, y })
    }
  }
}
github ustbhuangyi / better-scroll / packages / core / src / scroller / Scroller.ts View on Github external
disable() {
    cancelAnimationFrame(this.animater.timer)
    this.actions.enabled = false
  }