How to use the react-overlays.Position.prototype function in react-overlays

To help you get started, we’ve selected a few react-overlays 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 baidu / amis / src / components / Overlay.tsx View on Github external
/**
 * @file Overlay
 * @description
 * @author fex
 */

import {Position, Overlay as BaseOverlay} from 'react-overlays';
import {findDOMNode} from 'react-dom';
import React from 'react';
import {calculatePosition, getContainer, ownerDocument} from '../utils/dom';

Position.propTypes.placement = BaseOverlay.propTypes.placement = () => null;

Position.prototype.updatePosition = function(target: any) {
  this._lastTarget = target;

  if (!target) {
    return this.setState({
      positionLeft: 0,
      positionTop: 0,
      arrowOffsetLeft: null,
      arrowOffsetTop: null
    });
  }

  const overlay = findDOMNode(this);
  const container = getContainer(
    this.props.container,
    ownerDocument(this).body
  );