How to use the @better-scroll/shared-utils.Direction.Negative 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 / scroller / Behavior.ts View on Github external
move(delta: number) {
    delta = this.hasScroll ? delta : 0
    this.movingDirection =
      delta > 0
        ? Direction.Negative
        : delta < 0
        ? Direction.Positive
        : Direction.Default

    let newPos = this.currentPos + delta

    // Slow down or stop if outside of the boundaries
    if (newPos > this.minScrollPos || newPos < this.maxScrollPos) {
      if (
        (newPos > this.minScrollPos && this.options.bounces[0]) ||
        (newPos < this.maxScrollPos && this.options.bounces[1])
      ) {
        newPos = this.currentPos + delta / 3
      } else {
        newPos =
          newPos > this.minScrollPos ? this.minScrollPos : this.maxScrollPos
github ustbhuangyi / better-scroll / packages / core / src / scroller / Behavior.ts View on Github external
let momentumInfo: {
      destination?: number
      duration?: number
    } = {
      duration: 0
    }

    const absDist = Math.abs(this.currentPos - this.startPos)
    // start momentum animation if needed
    if (
      this.options.momentum &&
      duration < this.options.momentumLimitTime &&
      absDist > this.options.momentumLimitDistance
    ) {
      const wrapperSize =
        (this.direction === Direction.Negative && this.options.bounces[0]) ||
        (this.direction === Direction.Positive && this.options.bounces[1])
          ? this.wrapperSize
          : 0

      momentumInfo = this.hasScroll
        ? this.momentum(
            this.currentPos,
            this.startPos,
            duration,
            this.maxScrollPos,
            this.minScrollPos,
            wrapperSize,
            this.options
          )
        : { destination: this.currentPos, duration: 0 }
    } else {
github ustbhuangyi / better-scroll / packages / pull-down / src / index.ts View on Github external
private _checkPullDown() {
    if (!this.scroll.options.pullDownRefresh) {
      return
    }

    const { threshold = 90, stop = 40 } = this.scroll.options
      .pullDownRefresh as PullDownRefreshConfig

    // check if a real pull down action
    if (
      this.scroll.directionY !== Direction.Negative ||
      this.scroll.y < threshold
    ) {
      return false
    }

    if (!this.pulling) {
      this.pulling = true
      this.scroll.trigger('pullingDown')

      this.originalMinScrollY = this.scroll.minScrollY
      this.scroll.minScrollY = stop
    }

    this.scroll.scrollTo(
      this.scroll.x,
      stop,
github ustbhuangyi / better-scroll / packages / mouse-wheel / src / index.ts View on Github external
break
    }
    wheelDeltaX *= direction
    wheelDeltaY *= direction

    if (!this.scroll.scroller.scrollBehaviorY.hasScroll) {
      wheelDeltaX = wheelDeltaY
      wheelDeltaY = 0
    }
    if (!this.scroll.scroller.scrollBehaviorX.hasScroll) {
      wheelDeltaX = 0
    }

    const directionX =
      wheelDeltaX > 0
        ? Direction.Negative
        : wheelDeltaX < 0
        ? Direction.Positive
        : 0
    const directionY =
      wheelDeltaY > 0
        ? Direction.Negative
        : wheelDeltaY < 0
        ? Direction.Positive
        : 0
    return {
      x: wheelDeltaX,
      y: wheelDeltaY,
      directionX,
      directionY
    }
  }
github ustbhuangyi / better-scroll / packages / core / src / scroller / Behavior.ts View on Github external
updateDirection() {
    const absDist = Math.round(this.currentPos) - this.absStartPos
    this.direction =
      absDist > 0
        ? Direction.Negative
        : absDist < 0
        ? Direction.Positive
        : Direction.Default
  }
github ustbhuangyi / better-scroll / packages / mouse-wheel / src / index.ts View on Github external
wheelDeltaX = wheelDeltaY
      wheelDeltaY = 0
    }
    if (!this.scroll.scroller.scrollBehaviorX.hasScroll) {
      wheelDeltaX = 0
    }

    const directionX =
      wheelDeltaX > 0
        ? Direction.Negative
        : wheelDeltaX < 0
        ? Direction.Positive
        : 0
    const directionY =
      wheelDeltaY > 0
        ? Direction.Negative
        : wheelDeltaY < 0
        ? Direction.Positive
        : 0
    return {
      x: wheelDeltaX,
      y: wheelDeltaY,
      directionX,
      directionY
    }
  }
  private beforeHandler(e: CompatibleWheelEvent) {