How to use the @better-scroll/shared-utils.isUndef 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 / Scroller.ts View on Github external
private momentum(pos: TranslaterPoint, duration: number) {
    const meta = {
      time: 0,
      easing: ease.swiper,
      newX: pos.x,
      newY: pos.y
    }
    // start momentum animation if needed
    const momentumX = this.scrollBehaviorX.end(duration)
    const momentumY = this.scrollBehaviorY.end(duration)

    meta.newX = isUndef(momentumX.destination)
      ? meta.newX
      : (momentumX.destination as number)
    meta.newY = isUndef(momentumY.destination)
      ? meta.newY
      : (momentumY.destination as number)
    meta.time = Math.max(
      momentumX.duration as number,
      momentumY.duration as number
    )

    this.hooks.trigger(this.hooks.eventTypes.momentum, meta, this)
    // when x or y changed, do momentum animation now!
    if (meta.newX !== pos.x || meta.newY !== pos.y) {
      // change easing function when scroller goes out of the boundaries
      if (
        meta.newX > this.scrollBehaviorX.minScrollPos ||
        meta.newX < this.scrollBehaviorX.maxScrollPos ||
        meta.newY > this.scrollBehaviorY.minScrollPos ||
        meta.newY < this.scrollBehaviorY.maxScrollPos
github ustbhuangyi / better-scroll / packages / core / src / scroller / Scroller.ts View on Github external
private momentum(pos: TranslaterPoint, duration: number) {
    const meta = {
      time: 0,
      easing: ease.swiper,
      newX: pos.x,
      newY: pos.y
    }
    // start momentum animation if needed
    const momentumX = this.scrollBehaviorX.end(duration)
    const momentumY = this.scrollBehaviorY.end(duration)

    meta.newX = isUndef(momentumX.destination)
      ? meta.newX
      : (momentumX.destination as number)
    meta.newY = isUndef(momentumY.destination)
      ? meta.newY
      : (momentumY.destination as number)
    meta.time = Math.max(
      momentumX.duration as number,
      momentumY.duration as number
    )

    this.hooks.trigger(this.hooks.eventTypes.momentum, meta, this)
    // when x or y changed, do momentum animation now!
    if (meta.newX !== pos.x || meta.newY !== pos.y) {
      // change easing function when scroller goes out of the boundaries
      if (
        meta.newX > this.scrollBehaviorX.minScrollPos ||
github ustbhuangyi / better-scroll / packages / core / src / index.ts View on Github external
static use(ctor: PluginCtor) {
    const name = ctor.pluginName
    const installed = this.plugins.some(plugin => ctor === plugin.ctor)
    if (installed) return this
    if (isUndef(name)) {
      warn(
        `Plugin Class must specify plugin's name in static property by 'pluginName' field.`
      )
      return this
    }
    if (this.pluginsMap[name]) {
      warn(
        `This plugin has been registered, maybe you need change plugin's name`
      )
      return this
    }
    this.pluginsMap[name] = true
    this.plugins.push({
      name,
      enforce: ctor.enforce,
      ctor