How to use the @better-scroll/shared-utils.warn 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 / mouse-wheel / src / index.ts View on Github external
private getEaseTime() {
    const DEFAULT_EASETIME = 300
    const SAFE_EASETIME = 100
    const easeTime = this.mouseWheelOpt.easeTime || DEFAULT_EASETIME
    // scrollEnd event will be triggered in every calling of scrollTo when easeTime is too small
    // easeTime needs to be greater than 100
    if (easeTime < SAFE_EASETIME) {
      warn(`easeTime should be greater than 100.
      If mouseWheel easeTime is too small, scrollEnd will be triggered many times.`)
    }
    return easeTime
  }
}
github ustbhuangyi / better-scroll / packages / core / src / index.ts View on Github external
'scrollEnd',
      'scrollCancel',
      'touchEnd',
      'flick',
      'destroy'
    ])

    const wrapper = getElement(el)

    if (!wrapper) {
      warn('Can not resolve the wrapper DOM.')
      return
    }
    const content = wrapper.children[0]
    if (!content) {
      warn('The wrapper need at least one child element to be scroller.')
      return
    }
    this.plugins = {}
    this.options = new Options().merge(options).process()
    this.hooks = new EventEmitter([
      'init',
      'refresh',
      'enable',
      'disable',
      'destroy'
    ])
    this.init(wrapper)
  }
github ustbhuangyi / better-scroll / packages / core / src / index.ts View on Github external
'enable',
      'disable',
      'beforeScrollStart',
      'scrollStart',
      'scroll',
      'scrollEnd',
      'scrollCancel',
      'touchEnd',
      'flick',
      'destroy'
    ])

    const wrapper = getElement(el)

    if (!wrapper) {
      warn('Can not resolve the wrapper DOM.')
      return
    }
    const content = wrapper.children[0]
    if (!content) {
      warn('The wrapper need at least one child element to be scroller.')
      return
    }
    this.plugins = {}
    this.options = new Options().merge(options).process()
    this.hooks = new EventEmitter([
      'init',
      'refresh',
      'enable',
      'disable',
      'destroy'
    ])
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
    })
    return this
  }
github ustbhuangyi / better-scroll / packages / slide / src / SlidePage.ts View on Github external
private checkSlideLoop() {
    this.needLoop = this.slideOpt.loop!
    if (this.pagesPos.xLen > 1) {
      this.slideX = true
    }
    if (this.pagesPos.pages[0] && this.pagesPos.yLen > 1) {
      this.slideY = true
    }
    this.loopX = this.needLoop && this.slideX
    this.loopY = this.needLoop && this.slideY

    if (this.slideX && this.slideY) {
      warn('slide does not support two direction at the same time.')
    }
  }
}