Skip to content

iamjoshellis/react-handheld-portal-device

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

49 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

React Handheld Portal Device ๐ŸŒ€

npm Build Status code style: prettier Greenkeeper badge Netlify Status

Makes positioning portaled tooltips/dropdowns/etc a piece of cake ๐Ÿฐ!

Usage

import React from 'react';
import Portal from 'react-handheld-portal-device';

const Component = () => (
  <Parent>
    <Portal>
      (parentRect => <Content style={{ position: 'fixed', top: parentRect.top, left: parentRect.left,  }} />)
    </Portal>
  </Parent>
);

Using the render props pattern the Content can be "aware" of Parent's parentRect, which is the result of calling getBoundingClientRect on the Parent DOM node.

Props

class Portal extends React.Component {
  static propTypes = {
    debounce: PropTypes.number, // set the debounce time for event listeners
  };

  static defaultProps = {
    debounce: 16,
  };

  ...
}

Releases

No releases published

Packages

No packages published