How to use the @react-md/utils.positionRelativeTo function in @react-md/utils

To help you get started, we’ve selected a few @react-md/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 mlaursen / react-md / packages / tooltip / src / MagicTooltipConsumer.tsx View on Github external
case "right":
        horizontalPosition = HorizontalPosition.RIGHT;
        horizontalSpacing = spacing;
        break;
      case "top":
        verticalPosition = VerticalPosition.TOP;
        verticalSpacing = spacing;
        break;
      case "bottom":
        verticalPosition = VerticalPosition.BOTTOM;
        verticalSpacing = spacing;
        break;
    }

    this.setState({
      style: positionRelativeTo(container, tooltip, {
        horizontalPosition,
        verticalPosition,
        horizontalSpacing,
        verticalSpacing,
        isPortalFixed: portal || !!(portalIntoId || portalInto),
      }),
      position,
    });
  };
github mlaursen / react-md / packages / transition / src / hooks / useRelativePositioningStyle.ts View on Github external
(node, isAppearing) => {
      if (onEnter) {
        onEnter(node, isAppearing);
      }

      setStyle(
        positionRelativeTo(fixedToRef.current, node, optionsRef.current)
      );
    },
    [onEnter]
github mlaursen / react-md / packages / tooltip / src_old / hooks.ts View on Github external
function handleEnter(node: Maybe) {
    const nextPosition = determineBestPosition(
      container.current,
      positionConfig
    );

    if (position !== nextPosition) {
      setPosition(nextPosition);
    }

    if (!node || !portal) {
      return;
    }

    const nextStyle = positionRelativeTo(
      container.current,
      node,
      createPositionOptions(nextPosition, getSpacing(config))
    );

    setStyle(nextStyle);
  }
github mlaursen / react-md / v2scapped / documentation / src / components / packages / Portal / Examples / OverflowPortalExample / Cell.tsx View on Github external
private showTooltip = () => {
    const container = this.container.current;
    if (!container || this.state.visible) {
      return;
    }

    const tooltip = document.getElementById(container.getAttribute("aria-describedby") as string);
    this.setState({
      tooltipStyle: positionRelativeTo(container, tooltip, {
        verticalPosition: "below",
        verticalSpacing: "1.5rem",
        isPortalFixed: this.props.portal,
      }),
      visible: true,
    });
  };
github mlaursen / react-md / packages / documentation / src / components / packages / Portal / Examples / OverflowPortalExample / Cell.tsx View on Github external
private showTooltip = () => {
    const container = this.container.current;
    if (!container || this.state.visible) {
      return;
    }

    const tooltip = document.getElementById(container.getAttribute("aria-describedby") as string);
    this.setState({
      tooltipStyle: positionRelativeTo(container, tooltip, {
        verticalPosition: "below",
        verticalSpacing: "1.5rem",
        isPortalFixed: this.props.portal,
      }),
      visible: true,
    });
  };