How to use the @better-scroll/core function in @better-scroll/core

To help you get started, we’ve selected a few @better-scroll/core 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 / pull-up / src / __tests__ / index.spec.ts View on Github external
beforeAll(() => {
    // create DOM
    const wrapper = document.createElement('div')
    const content = document.createElement('div')
    wrapper.appendChild(content)
    // mock bscroll
    bscroll = new BScroll(wrapper, {})
    bscroll.maxScrollY = MAX_SCROLL_Y
    bscroll.movingDirectionY = MOVING_DIRECTION_Y
  })
github ustbhuangyi / better-scroll / packages / scroll-bar / src / __tests__ / index.spec.ts View on Github external
beforeAll(() => {
    // create Dom
    const wrapper = document.createElement('div')
    const content = document.createElement('div')
    wrapper.appendChild(content)
    // mock bscroll
    options = {
      scrollbar: CONFIG_SCROLL_BAR,
      scrollX: true,
      scrollY: true
    }
    bscroll = new BScroll(wrapper, options)
  })
github ustbhuangyi / better-scroll / packages / nested-scroll / src / __tests__ / index.spec.ts View on Github external
it("should make childScroll'options.click false when both BScroll' options.click are true", () => {
    const parentScroll = new BScroll(parentWrapper, {
      click: true
    })
    const childScroll = new BScroll(childWrapper, {
      click: true
    })
    let nestedScroll1 = new NestedScroll(parentScroll)
    let nestedScroll2 = new NestedScroll(childScroll)

    expect(childScroll.options.click).toBe(false)
  })
})
github ustbhuangyi / better-scroll / packages / zoom / src / __tests__ / Zoom.spec.ts View on Github external
function createBScroll(
  hooks: EventEmitter,
  zoomOptions: {
    start: number
    min: number
    max: number
  }
) {
  const mockscrollTo = jest.fn()
  const { partOfbscroll, dom } = bscrollZoom(zoomOptions)
  const bscroll = new BScroll(dom) as any
  replaceBscrollProperties(bscroll, partOfbscroll)
  bscroll.hooks = hooks
  bscroll.scroller.hooks = hooks
  bscroll.scroller.translater.hooks = hooks
  bscroll.scroller.animater = {
    hooks: hooks
  }
  bscroll.scroller.actions = {
    hooks: hooks
  }
  bscroll.scroller.scrollTo = mockscrollTo
  return {
    bscroll,
    mockscrollTo
  }
}
github ustbhuangyi / better-scroll / packages / observe-dom / src / __tests__ / ObserveDom.spec.ts View on Github external
function createBS() {
  const dom = createDiv(300, 300)
  const contentDom = createDiv(300, 300)
  dom.appendChild(contentDom)
  const bs = new BScroll(dom) as any
  return bs
}
github falstack / v-switcher / examples / VueScroll.vue View on Github external
_initScroll() {
      if (!this.$refs.wrapper) {
        return
      }
      this.scroll = new BScroll(this.$refs.wrapper, {
        probeType: this.event ? 2 : 0,
        click: true,
        scrollX: this.scrollX,
        scrollY: !this.scrollX,
        stopPropagation: this.stop
      })
      if (this.event) {
        this.scroll.on('scroll', ({ y }) => {
          const direction = this.scroll.movingDirectionY
          this.$emit('scroll', {
            offset: Math.max(-y, 0),
            isUp: direction === -1
          })
          if (direction === -1) {
            if (y > -50) {
              this.$emit('pull-down')
github ustbhuangyi / better-scroll / packages / examples / vue / components / pulldown / default.vue View on Github external
initBscroll() {
        this.bscroll = new BScroll(this.$refs.bsWrapper, {
          scrollY: true,
          bounceTime: TIME_BOUNCE,
          pullDownRefresh: {
            threshold: THRESHOLD,
            stop: STOP
          }
        })

        this.bscroll.on('pullingDown', this.pullingDownHandler)
        this.bscroll.on('scroll', this.scrollHandler)
      },
      scrollHandler(pos) {
github ustbhuangyi / better-scroll / packages / examples / vue / components / infinity / default.vue View on Github external
createInfinityScroll() {
        this.scroll = new BScroll(this.$refs.chat, {
          infinity: {
            render: (item, div) => {
              div = div || this.$refs.message.cloneNode(true)
              div.dataset.id = item.id
              div.querySelector('.infinity-avatar').src = require(`./image/avatar${item.avatar}.jpg`)
              div.querySelector('.infinity-bubble p').textContent = item.id + '  ' + item.message
              div.querySelector('.infinity-bubble .infinity-posted-date').textContent = item.time.toString()

              let img = div.querySelector('.infinity-bubble img')
              if (item.image !== '') {
                img.style.display = ''
                img.src = item.image.src
                img.width = item.image.width
                img.height = item.image.height
              } else {
                img.src = ''
github ustbhuangyi / better-scroll / packages / examples / vue / components / scrollbar / default.vue View on Github external
initBscroll() {
        this.bscroll = new BScroll(this.$refs.scroller, {
          scrollY: true,
          scrollbar: true
        })
      }
    }
github ustbhuangyi / better-scroll / packages / examples / vue / components / nested-scroll / horizontal-in-vertical.vue View on Github external
initScroll () {
      let outerScroll = new BScroll(this.$refs.outerScroll, {
        nestedScroll: true
      })

      let innerScroll = new BScroll(this.$refs.innerScroll, {
        nestedScroll: true,
        scrollX: true,
        scrollY: false,
        slide: {
          loop: true,
          threshold: 100
        },
        useTransition: true,
        momentum: false,
        bounce: false
      })
    }