How to use the @better-scroll/shared-utils.EventRegister 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 / base / __mocks__ / ActionsHandler.ts View on Github external
.mockImplementation((wrapper, bscrollOptions) => {
    return {
      wrapper,
      options: bscrollOptions,
      initiated: 1,
      pointX: 0,
      pointY: 0,
      startClickRegister: new EventRegister(wrapper, []),
      moveEndRegister: new EventRegister(wrapper, []),
      hooks: new EventEmitter(['beforeStart', 'start', 'move', 'end', 'click']),
      destroy: jest.fn()
    }
  })
github ustbhuangyi / better-scroll / packages / scroll-bar / src / event-handler.ts View on Github external
constructor(
    public indicator: Indicator,
    public options: EventHandlerOptions
  ) {
    this.bscroll = indicator.bscroll
    this.startEventRegister = new EventRegister(this.indicator.el, [
      {
        name: options.disableMouse ? 'touchstart' : 'mousedown',
        handler: this._start.bind(this)
      }
    ])

    this.endEventRegister = new EventRegister(window, [
      {
        name: options.disableMouse ? 'touchend' : 'mouseup',
        handler: this._end.bind(this)
      }
    ])
    this.hooks = new EventEmitter(['touchStart', 'touchMove', 'touchEnd'])
  }
github ustbhuangyi / better-scroll / packages / core / src / base / __mocks__ / ActionsHandler.ts View on Github external
.mockImplementation((wrapper, bscrollOptions) => {
    return {
      wrapper,
      options: bscrollOptions,
      initiated: 1,
      pointX: 0,
      pointY: 0,
      startClickRegister: new EventRegister(wrapper, []),
      moveEndRegister: new EventRegister(wrapper, []),
      hooks: new EventEmitter(['beforeStart', 'start', 'move', 'end', 'click']),
      destroy: jest.fn()
    }
  })
github ustbhuangyi / better-scroll / packages / core / src / scroller / __mocks__ / Scroller.ts View on Github external
'refresh',
      'touchEnd',
      'end',
      'flick',
      'scrollCancel',
      'momentum',
      'scrollTo',
      'scrollToElement',
      'transitionEnd',
      'checkClick',
      'ignoreDisMoveForSamePos'
    ]),
    scrollBehaviorX,
    scrollBehaviorY,
    resizeRegister: new EventRegister(wrapper, []),
    transitionEndRegister: new EventRegister(wrapper, [])
  }
})
github ustbhuangyi / better-scroll / packages / scroll-bar / src / event-handler.ts View on Github external
constructor(
    public indicator: Indicator,
    public options: EventHandlerOptions
  ) {
    this.bscroll = indicator.bscroll
    this.startEventRegister = new EventRegister(this.indicator.el, [
      {
        name: options.disableMouse ? 'touchstart' : 'mousedown',
        handler: this._start.bind(this)
      }
    ])

    this.endEventRegister = new EventRegister(window, [
      {
        name: options.disableMouse ? 'touchend' : 'mouseup',
        handler: this._end.bind(this)
      }
    ])
    this.hooks = new EventEmitter(['touchStart', 'touchMove', 'touchEnd'])
  }
github ustbhuangyi / better-scroll / packages / core / src / scroller / __mocks__ / Scroller.ts View on Github external
'scrollEnd',
      'refresh',
      'touchEnd',
      'end',
      'flick',
      'scrollCancel',
      'momentum',
      'scrollTo',
      'scrollToElement',
      'transitionEnd',
      'checkClick',
      'ignoreDisMoveForSamePos'
    ]),
    scrollBehaviorX,
    scrollBehaviorY,
    resizeRegister: new EventRegister(wrapper, []),
    transitionEndRegister: new EventRegister(wrapper, [])
  }
})
github ustbhuangyi / better-scroll / packages / scroll-bar / src / event-handler.ts View on Github external
private _start(e: TouchEvent) {
    let point = (e.touches ? e.touches[0] : e) as Touch

    e.preventDefault()
    e.stopPropagation()

    this.initiated = true
    this.moved = false
    this.lastPoint = point[this.indicator.keysMap.pointPos]

    const { disableMouse } = this.bscroll.options
    this.moveEventRegister = new EventRegister(window, [
      {
        name: disableMouse ? 'touchmove' : 'mousemove',
        handler: this._move.bind(this)
      }
    ])
    this.hooks.trigger('touchStart')
  }