JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q22136F
  • License MIT

HighWall is a React component which fits viewport's height. It is like a mobile browser compatible 100vh div.

Package Exports

  • highwall

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (highwall) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

HighWall - A React Component

Summary

CSS height: 100vh is useful when trying to implement native-app-like mobile web application. However, on mobile Safari for example, it does not work as expected.

This "HighWall" is a React component which realizes height: 100vh by measuring viewport's height every window size change.

React version

Since this component uses hook internally, React version has to be greater than 16.8.0.

How to use

Green will fill up the viewport. Of course, you can set your own class like <HighWall className="myClass">.

import {HighWall} from 'HighWall';

const Page: React.FC = () => {
  return (
    <HighWall style={{backgroundColor: 'green'}}>
      <div>Child component</div>
    </HighWall>  
  );
};

These settings will show debug information on head-up display.

<HighWall debug={true}> // show in default position, leftBottom.
<HighWall debug={position: 'rightBottom'}>

Advanced

Maybe sometimes you want to set viewport's height to min-height or other properties. This can be realized by setting Fitter function in props.

This sample will set the height to min-height instead of height.

import {HighWall, Fitter} from 'HighWall';

const fitter: Fitter = viewportHeight => ({minHeight: viewportHeight});
<HighWall fitter={fitter}>
</HighWall>

This component has throttle to avoid too frequent rerender. The default value is 150 milliseconds.

<HighWall throttle={1000}> // this will limit height update to every 1 second.

Thanks

This component was inspired by great repos and articles, especially: