# react-scroll-detect

> Scroll detect component

Latest version **1.2.0** (published 2020-03-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-scroll-detect
pnpm add react-scroll-detect
yarn add react-scroll-detect
bun add react-scroll-detect
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2020-03-10 |
| First published | 2020-03-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 51.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mukut Brahma |
| Maintainers | mukut |
| Keywords | react, scroll, scroll detect, react scroll |

## Links

- npm: https://www.npmjs.com/package/react-scroll-detect
- npm.io page: https://npm.io/package/react-scroll-detect

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2020-03-10
- 1.1.3 — 2020-03-06
- 1.1.2 — 2020-03-05
- 1.1.1 — 2020-03-05
- 1.1.0 — 2020-03-05
- 1.0.1 — 2020-03-05
- 1.0.0 — 2020-03-05

## README

![Version](https://img.shields.io/npm/v/react-scroll-detect)
[![Build](https://img.shields.io/appveyor/build/g30elipse/react-scroll-detect)](https://ci.appveyor.com/project/g30elipse/react-scroll-detect)
[![Dependencies](https://img.shields.io/david/g30elipse/react-scroll-detect)](https://david-dm.org/g30elipse/react-scroll-detect)
[![Bundle size](https://img.shields.io/bundlephobia/minzip/react-scroll-detect)](https://bundlephobia.com/result?p=react-scroll-detect@1.1.2)
![License](https://img.shields.io/npm/l/react-scroll-detect)


# react-scroll-detect
A set of utility components to watch scroll changes.

[Codesandbox demo](https://codesandbox.io/s/inspiring-goldwasser-5k13y?fontsize=14&hidenavigation=1&theme=dark)

### Components


#### DetectSection
Wrap your component with `DetectSection` to attach it to the listener. `ReactScrollDetect` will call `onChange` 
event whenever the component wrapped with `DetectSection` enters the viewport.

##### props
| props    | signature               | required       | description |
|------    | --------------         | ----           | ----------- |
| - | - | - | - |


#### ReactScrollDetect
This is a wrapper component for your scrollable component. Wrap your component with `ReactScrollDetect` and attach the `onChange` listener.

##### props
| props    | signature               | required   | default value     | description |
|------    | --------------         | ----        | -----------       | -------- |
| onChange | (index: number) => void | false      | () => null        | Function which is exectuted when a new section enters the viewport |
| triggerPoint | 'center', 'top', 'bottom | false | 'center'        | Trigger point for DetectSection (default: center) |
| index    | number                  | false      | 0    | This spectifies which section(index) the needs to be scrolled to the viewport.(note: this is an experimental feature)  |
| offset    | number                  | false      |0     |The offset from the top (of the screen) for the scroll to snap |


#### Example
```typescript
import ReactScrollDetect, { DetectSection } from 'react-scroll-detect';
```

```jsx
<ReactScrollDetect triggerPoint='center' onChange={handleSectionChange}>
  <DetectSection>
    <div style={{height: 500}}/>
  </DetectSection>
  <DetectSection>
    <div style={{height: 700}}/>
  </DetectSection>
  <DetectSection>
    <div style={{height: 400}}/>
  </DetectSection>
</ReactScrollDetect>
```

---
_Source: https://npm.io/package/react-scroll-detect · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
