# @chris221/react-scroll-detect

> Scroll detect component

Latest version **1.0.3** (published 2022-08-18) · ISC license · 0 weekly downloads

## Install

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

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-08-18 |
| First published | 2022-08-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 63.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Chris Siena |
| Maintainers | chris221 |
| Keywords | react, scroll, scroll detect, react scroll |

## Links

- npm: https://www.npmjs.com/package/@chris221/react-scroll-detect
- Repository: https://github.com/Chris221/react-scroll-detect
- Homepage: https://github.com/Chris221/react-scroll-detect#readme
- Issues: https://github.com/Chris221/react-scroll-detect/issues
- npm.io page: https://npm.io/package/@chris221/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.0.3 (latest) — 2022-08-18
- 1.0.2 — 2022-08-18
- 1.0.0 — 2022-08-18

## README

[![Version](https://img.shields.io/npm/v/@chris221/react-scroll-detect)](https://www.npmjs.com/package/@chris221/react-scroll-detect)
[![Build status](https://ci.appveyor.com/api/projects/status/7nuk7aqsi6nq7c5l?svg=true)](https://ci.appveyor.com/project/Chris221/react-scroll-detect)
[![Bundle size](https://img.shields.io/bundlephobia/minzip/@chris221/react-scroll-detect)](https://bundlephobia.com/package/@chris221/react-scroll-detect)
![License](https://img.shields.io/npm/l/@chris221/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)

## Install

`npm install --save @chris221/react-scroll-detect`

or

`yarn add @chris221/react-scroll-detect`

### Fork

Forked from [g30elipse/react-scroll-detect](https://github.com/g30elipse/react-scroll-detect)

### 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/@chris221/react-scroll-detect · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
