How to use the @instructure/ui-dom-utils.getScrollParents function in @instructure/ui-dom-utils

To help you get started, we’ve selected a few @instructure/ui-dom-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 instructure / instructure-ui / packages / ui-layout / src / calculateElementPosition.js View on Github external
get scrollParentsOffset () {
    const parents = getScrollParents(this.node)

    let offsetY = 0
    let offsetX = 0

    for (let i = 1; i < parents.length; i++) {
      const parent = parents[i]
      const child = parents[i - 1]

      offsetY = offsetY + (this.normalizeScrollTop(parent) - this.normalizeScrollTop(child))
      offsetX = offsetX + (parent.scrollLeft - child.scrollLeft)
    }

    return { top: offsetY, left: offsetX }
  }
github instructure / instructure-ui / packages / ui-layout / src / calculateElementPosition.js View on Github external
if (!element || placement === 'offscreen') return

    this.container = container || ownerDocument(element).body

    this.element = new PositionedElement(element, placement, { top: this.options.offsetY, left: this.options.offsetX })

    this.target = new PositionedElement(
      target || this.container,
      over ? this.element.placement : this.element.mirroredPlacement
    )

    if (constrain === 'window') {
      this.constrainTo(ownerWindow(element))
    } else if (constrain === 'scroll-parent') {
      this.constrainTo(getScrollParents(this.target.node)[0])
    } else if (constrain === 'parent') {
      this.constrainTo(this.container)
    } else if (typeof constrain === 'function') {
      this.constrainTo(findDOMNode(constrain.call(null)))
    } else if (typeof constrain === 'object') {
      this.constrainTo(findDOMNode(constrain))
    }
  }