https://github.com/jossmac/react-scroll-captor
📜 Restrict scroll events to the immediate child
https://github.com/jossmac/react-scroll-captor
react scroll
Last synced: about 1 year ago
JSON representation
📜 Restrict scroll events to the immediate child
- Host: GitHub
- URL: https://github.com/jossmac/react-scroll-captor
- Owner: jossmac
- License: mit
- Created: 2018-02-10T10:30:35.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-23T21:00:43.000Z (over 8 years ago)
- Last Synced: 2025-04-30T22:48:53.342Z (about 1 year ago)
- Topics: react, scroll
- Language: JavaScript
- Homepage:
- Size: 46.9 KB
- Stars: 27
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 📜 React Scroll Captor
A component that confines scroll events to its immediate child. Great for dropdown menus etc.
### Install
```bash
yarn add react-scroll-captor
```
### Use
```jsx
import ScrollCaptor from 'react-scroll-captor';
class GroovyThing extends Component {
atBottom = () => {
// user has scrolled to the bottom
}
render () {
return (
);
}
}
```
### Props
| Property | Type | Default | Description |
| ---------------- | ---------- | ---------- | ----------- |
| `isEnabled` | `boolean` | `true` | Enable or disable the component. |
| `onBottomArrive` | `function` | -- | Called when the user reaches the bottom of the scrollable element. |
| `onBottomLeave` | `function` | -- | Called when the user leaves the bottom of the scrollable element. |
| `onTopArrive` | `function` | -- | Called when the user reaches the top of the scrollable element. |
| `onTopLeave` | `function` | -- | Called when the user leaves the top of the scrollable element. |