How to use the @instructure/ui-dom-utils.ownerWindow 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
overflow (element) {
    const parentWindow = ownerWindow(element)
    const elementBounds = getBoundingClientRect(element)
    const windowBounds = getBoundingClientRect(parentWindow)
    const offsets = addOffsets([this.target.position, this.offset])
    const parentOffset = {
      top: this.element.positionedParentsOffset.top + this.element.scrollParentsOffset.top,
      left: this.element.positionedParentsOffset.left + this.element.scrollParentsOffset.left
    }

    let left = offsets.left + parentOffset.left
    let right = offsets.left + this.element.width + parentOffset.left

    let top = offsets.top + parentOffset.top
    let bottom = offsets.top + this.element.height + parentOffset.top

    // adjust for vertical placements
    if (this.element.placement[0] === "bottom") {
github instructure / instructure-ui / packages / ui-react-utils / src / windowMessageListener.js View on Github external
componentDidMount () {
       const win = ownerWindow(this)

       win.addEventListener('message', this.handleMessage, false)

       if (super.componentDidMount) {
         super.componentDidMount()
       }
     }
github instructure / instructure-ui / packages / ui-react-utils / src / windowMessageListener.js View on Github external
function origin (node) {
  const ownWindow = ownerWindow(node)

  const { location } = ownWindow


  if (location.protocol === 'file:') {
    return '*'
  } else if (location.origin) {
    return location.origin
  } else if (location.port) {
    return `${location.protocol}//${location.hostname}:${location.port}`
  } else {
    return `${location.protocol}//${location.hostname}`
  }
}
github instructure / instructure-ui / packages / ui-react-utils / src / windowMessageListener.js View on Github external
componentWillUnmount () {
       const win = ownerWindow(this)
       win.removeEventListener('message', this.handleMessage, false)

       if (super.componentDidMount) {
         super.componentDidMount()
       }
     }
github instructure / instructure-ui / packages / ui-layout / src / calculateElementPosition.js View on Github external
const { container, constrain, placement, over } = this.options

    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))
    }
  }