How to use the @better-scroll/shared-utils.getRect 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 / wheel / src / index.ts View on Github external
refresh() {
    const scroller = this.scroll.scroller
    const scrollBehaviorY = scroller.scrollBehaviorY

    // adjust contentSize
    const contentRect = getRect(scroller.content)
    scrollBehaviorY.contentSize = contentRect.height

    this.items = scroller.content.children
    this.checkWheelAllDisabled()

    this.itemHeight = this.items.length
      ? scrollBehaviorY.contentSize / this.items.length
      : 0

    if (this.selectedIndex === undefined) {
      this.selectedIndex = this.options.selectedIndex || 0
    }

    this.scroll.maxScrollX = 0
    this.scroll.maxScrollY = -this.itemHeight * (this.items.length - 1)
    this.scroll.minScrollX = 0
github ustbhuangyi / better-scroll / packages / core / src / scroller / Behavior.ts View on Github external
refresh() {
    const { size, position } = this.options.rect
    const isWrapperStatic =
      window.getComputedStyle(this.wrapper, null).position === 'static'
    const wrapperRect = getRect(this.wrapper)
    this.wrapperSize = wrapperRect[size]

    const contentRect = getRect(this.content)
    this.contentSize = contentRect[size]

    this.relativeOffset = contentRect[position]
    if (isWrapperStatic) {
      this.relativeOffset -= wrapperRect[position]
    }

    this.minScrollPos = 0
    this.maxScrollPos = this.wrapperSize - this.contentSize
    if (this.maxScrollPos < 0) {
      this.maxScrollPos -= this.relativeOffset
      this.minScrollPos = -this.relativeOffset
    }
github ustbhuangyi / better-scroll / packages / observe-dom / src / index.ts View on Github external
function check() {
      if (me.stopObserver) {
        return
      }
      scrollerRect = getRect(scrollerEl)
      let newWidth = scrollerRect.width
      let newHeight = scrollerRect.height

      if (oldWidth !== newWidth || oldHeight !== newHeight) {
        scrollIns.refresh()
      }
      oldWidth = newWidth
      oldHeight = newHeight

      next()
    }
github ustbhuangyi / better-scroll / packages / observe-dom / src / index.ts View on Github external
private checkDOMUpdate() {
    const me = this
    const scrollIns = this.scroll
    const scrollerEl = scrollIns.scroller.content
    let scrollerRect = getRect(scrollerEl)
    let oldWidth = scrollerRect.width
    let oldHeight = scrollerRect.height

    function check() {
      if (me.stopObserver) {
        return
      }
      scrollerRect = getRect(scrollerEl)
      let newWidth = scrollerRect.width
      let newHeight = scrollerRect.height

      if (oldWidth !== newWidth || oldHeight !== newHeight) {
        scrollIns.refresh()
      }
      oldWidth = newWidth
      oldHeight = newHeight