leafiy
5/18/2018 - 6:47 PM

requestAnimationRequest 数数 #js

none

    let backward;
    let add = () => {
      if (!backward) {
        this.percent++

      }
      if (backward) {
        this.percent--
          if (this.percent <= 0) {
            backward = false
          }
      }
      let addTimer = requestAnimationFrame(add)
      if (this.percent == 100) {
        backward = true

      }

    }

    requestAnimationFrame(add)