How to use the @better-scroll/shared-utils.DirectionLock.Horizontal 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 / DirectionLock.ts View on Github external
private computeDirectionLock(absDistX: number, absDistY: number) {
    // If you are scrolling in one direction, lock it
    if (this.directionLocked === DirectionLock.Default && !this.freeScroll) {
      if (absDistX > absDistY + this.directionLockThreshold) {
        this.directionLocked = DirectionLock.Horizontal // lock horizontally
      } else if (absDistY >= absDistX + this.directionLockThreshold) {
        this.directionLocked = DirectionLock.Vertical // lock vertically
      } else {
        this.directionLocked = DirectionLock.None // no lock
      }
    }
  }
github ustbhuangyi / better-scroll / packages / core / src / scroller / DirectionLock.ts View on Github external
adjustDelta(deltaX: number, deltaY: number) {
    if (this.directionLocked === DirectionLock.Horizontal) {
      deltaY = 0
    } else if (this.directionLocked === DirectionLock.Vertical) {
      deltaX = 0
    }
    return {
      deltaX,
      deltaY
    }
  }
github ustbhuangyi / better-scroll / packages / core / src / scroller / DirectionLock.ts View on Github external
[key: string]: {
    [key: string]: EventPassthrough
  }
}

const PassthroughHandlers = {
  [Passthrough.Yes]: (e: TouchEvent) => {
    return true
  },
  [Passthrough.No]: (e: TouchEvent) => {
    e.preventDefault()
    return false
  }
}
const DirectionMap = {
  [DirectionLock.Horizontal]: {
    [Passthrough.Yes]: EventPassthrough.Horizontal,
    [Passthrough.No]: EventPassthrough.Vertical
  },
  [DirectionLock.Vertical]: {
    [Passthrough.Yes]: EventPassthrough.Vertical,
    [Passthrough.No]: EventPassthrough.Horizontal
  }
} as DirectionMap

export default class DirectionLockAction {
  directionLocked: DirectionLock
  constructor(
    public directionLockThreshold: number,
    public freeScroll: boolean,
    public eventPassthrough: string
  ) {