How to use the dom-helpers/ownerWindow function in dom-helpers

To help you get started, we’ve selected a few dom-helpers 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 zendeskgarden / react-components / packages / modals / src / elements / Modal.js View on Github external
const isOverflowing = element => {
  const doc = ownerDocument(element);
  const win = ownerWindow(doc);

  const isBody = element && element.tagName.toLowerCase() === 'body';

  /* istanbul ignore next */
  if (!isWindow(doc) && !isBody) {
    return element.scrollHeight > element.clientHeight;
  }

  const style = win.getComputedStyle(doc.body);
  const marginLeft = parseInt(style.getPropertyValue('margin-left'), 10);
  const marginRight = parseInt(style.getPropertyValue('margin-right'), 10);

  return marginLeft + doc.body.clientWidth + marginRight < win.innerWidth;
};
github deranjer / goTorrent / goTorrentWebUI / node_modules / material-ui / es / Popover / Popover.js View on Github external
const elemRect = {
        width: element.clientWidth,
        height: element.clientHeight
      };
      // Get the transform origin point on the element itself
      const transformOrigin = this.getTransformOrigin(elemRect, contentAnchorOffset);

      // Calculate element positioning
      let top = anchorOffset.top - transformOrigin.vertical;
      let left = anchorOffset.left - transformOrigin.horizontal;
      const bottom = top + elemRect.height;
      const right = left + elemRect.width;

      // Use the parent window of the anchorEl if provided
      const containerWindow = ownerWindow(getAnchorEl(anchorEl));

      // Window thresholds taking required margin into account
      const heightThreshold = containerWindow.innerHeight - marginThreshold;
      const widthThreshold = containerWindow.innerWidth - marginThreshold;

      // Check if the vertical axis needs shifting
      if (top < marginThreshold) {
        const diff = top - marginThreshold;
        top -= diff;
        transformOrigin.vertical += diff;
      } else if (bottom > heightThreshold) {
        const diff = bottom - heightThreshold;
        top -= diff;
        transformOrigin.vertical += diff;
      }
github deranjer / goTorrent / goTorrentWebUI / node_modules / material-ui / es / transitions / Slide.js View on Github external
function getTranslateValue(props, node) {
  const { direction } = props;
  const rect = node.getBoundingClientRect();

  let transform;

  if (node.fakeTransform) {
    transform = node.fakeTransform;
  } else {
    const computedStyle = ownerWindow(node).getComputedStyle(node);
    transform = computedStyle.getPropertyValue('-webkit-transform') || computedStyle.getPropertyValue('transform');
  }

  let offsetX = 0;
  let offsetY = 0;

  if (transform && transform !== 'none' && typeof transform === 'string') {
    const transformValues = transform.split('(')[1].split(')')[0].split(',');
    offsetX = parseInt(transformValues[4], 10);
    offsetY = parseInt(transformValues[5], 10);
  }

  if (direction === 'left') {
    return `translateX(100vw) translateX(-${rect.left - offsetX}px)`;
  } else if (direction === 'right') {
    return `translateX(-${rect.left + rect.width + GUTTER - offsetX}px)`;
github react-bootstrap / react-bootstrap / src / utils / domUtils.js View on Github external
function ownerWindow(componentOrElement) {
  let doc = ownerDocument(componentOrElement);
  return getOwnerWindow(doc);
}
github react-bootstrap / react-overlays / src / utils / ownerWindow.js View on Github external
export default function (componentOrElement) {
  return ownerWindow(ReactDOM.findDOMNode(componentOrElement));
}
github deranjer / goTorrent / goTorrentWebUI / node_modules / material-ui / es / ButtonBase / ButtonBase.js View on Github external
componentDidMount() {
    this.button = findDOMNode(this);
    listenForFocusKeys(ownerWindow(this.button));
  }