screen-cover
TypeScript icon, indicating that this package has built-in type declarations

0.3.9 • Public • Published

Screen-Cover

npm Build status CodeFactor

Demo

How to use

  1. Wrap you app with ScreenCoverProvider;
  2. Get showCover function from context and run it.
<ScreenCoverProvider>
  <App />
</ScreenCoverProvider>
const { showCover } = useScreenCover()
const handleClick = () => showCover(goToPageTwo, onEnd)

showCover receives onCover function (will be run once whole page is covered) and onEnd function (runs after animation is finished).

Class components

Use HOC withScreenCover which will pass showCover to props:

type Props = WithScreenCoverProps & OtherProps

class PageClass extends Component<Props> {...}

export default withScreenCover(PageClass)

Customisations

You can pass config to ScreenCoverProvider:

const screenCoverConfig = {
  coverTime: 500,
  uncoverTime: 4000,
  backgroundColor: "red"
}

...

<ScreenCoverProvider config={screenCoverConfig}>
  <App />
</ScreenCoverProvider>

All config properties are optional. You can also pass config to showCover to overwrite global config for selected call:

const showGreenCover = () => showCover(goToPageThree, undefined, { backgroundColor: "aquamarine" })

Package Sidebar

Install

npm i screen-cover

Weekly Downloads

2

Version

0.3.9

License

none

Unpacked Size

19.6 kB

Total Files

24

Last publish

Collaborators

  • shelchkov