@egauci/react-viewport

1.0.0 • Public • Published

Usage

npm install --save @egauci/react-viewport

To use in a component:

import ReactViewport from '@egauci/react-viewport';

const MyComponent = () => (
  <div>
    <p>Current Viewport Values:</p>
    <ReactViewport>
      {
        viewport => (
          <div>
            Scroll: {viewport.scrollX}, {viewport.scrollY}<br />
            Dimensions: {viewport.clientWidth}, {viewport.clientHeight}
          </div>
        )
      }
    </ReactViewport>
  </div>
);

Props:

milli - optional, defaults to 100. The window resize debounce period in milliseconds

render or children - a function that receives the viewport object and returns a React element.

The viewport object has several properties, the useful ones are shown in the example above.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.00latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.00
0.1.00

Package Sidebar

Install

npm i @egauci/react-viewport

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

6.55 kB

Total Files

3

Last publish

Collaborators

  • egauci