1.1.4 • Published 3 years ago

react-hide-on-scroll v1.1.4

Weekly downloads
123
License
MIT
Repository
github
Last release
3 years ago

Installation

  • To install from npm, run-
npm install --save react-hide-on-scroll
  • To install locally, clone this repo and in root directory, run-
npm run setup

Usage

  • Pass the element to be hidden as children to the components.
<HideBetween div startDivID="first" endDivID="third">
  <div className={classNames(styles.hide1to3, styles.sticky)}>
    hidden from div 1 to 3
  </div>
</HideBetween>
<HideOn divID="third">
  <div className={classNames(styles.sticky, styles.hideOnDiv)}>
    Hidden from third div
  </div>
</HideOn>
<HideScroll variant="down">
  <div className={classNames(styles.sticky, styles.hideScrollDown)}>
    Hidden on scrolling down
  </div>
</HideScroll>
<HideDuring>
  <div className={classNames(styles.sticky, styles.hideDuring)}>
    Hidden while scrolling
  </div>
</HideDuring>

API

To hide/show an element between 2 divs or between 2 specified heights(px)

PropsDescriptionTypeisOptional
childrenThe required react element that needs to be hiddenReactNodefalse
divTo hide between 2 specified divsbooleantrue
heightTo hide between 2 specified heightsbooleantrue
inverseSpecifying this will show the element instead of hiding, in specified breakpointsbooleantrue
startDivIDID of the div to start hiding fromstringtrue
endDivIDID of the div to stop hiding atstringtrue
startDivOffsetTo set an offset on the start position(in pixels) -- usable only with div propnumbertrue
endDivOffsetTo set an offset on the end position(in pixels) -- usable only with div propnumbertrue
startHeightHeight from where hiding must begin (in pixels)numbertrue
endHeightHeight where hiding must end (in pixels)numbertrue

To hide/show an element when reached a div or a specified height(px)

PropsDescriptionTypeisOptional
childrenThe required react element that needs to be hiddenReactNodefalse
atDivTo start hiding at a divbooleantrue
atHeightTo start hiding at a heightbooleantrue
inverseSpecifying this will show the element instead of hiding, in specified breakpointsbooleantrue
divIDID of the div to start hiding fromstringtrue
offsetTo set an offset on the hiding position(in pixels) -- usable only with div propnumbertrue
heightHeight from where hiding must begin (in pixels)numbertrue
showOnPageInitTo specify whether the element must be visible when the component first loadsbooleantrue

To hide/show an element during a scroll. (scroll to make element hidden/shown)

PropsDescriptionTypeisOptional
childrenThe required react element that needs to be hiddenReactNodefalse
inverseShows an element while scrolling instead of hiding itBooleantrue

To hide an element on scrolling up or down.

PropsDescriptionTypeisOptional
childrenThe required react element that needs to be hiddenReactNodefalse
variantTo specify whether the element must be hidden on scrolling up or down (down by default)"up" or "down"true
showOnPageInitTo specify whether the element must be visible when the component first loadsbooleantrue

Built using

  • Typescript
  • React
  • create-react-library

License

MIT © Pradeep-selva

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago