https://github.com/rt2zz/react-sticker
Colliding sticky headers
https://github.com/rt2zz/react-sticker
Last synced: 18 days ago
JSON representation
Colliding sticky headers
- Host: GitHub
- URL: https://github.com/rt2zz/react-sticker
- Owner: rt2zz
- Created: 2015-02-25T07:04:36.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-07-06T22:58:00.000Z (almost 10 years ago)
- Last Synced: 2025-04-24T01:06:11.041Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 172 KB
- Stars: 18
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## React Sticker
Creates instagram style sticky headers that collide when one header scrolls into another.If you need something like this, but this does not work out of the box for you, file an issue and I will work to add configuration options to support a wider set of use cases.
**Note:** This does not follow idiomatic react. The primary goal of this project is to be performant during scrolling and clean to implement.
**Example**
[react-sticker-example](https://github.com/rt2zz/react-sticker-example)### Usage
Create a parent component and put your sticky headers inside of it.*general*
```js...
...```
*example*
```js
var Sticker = require('react-sticker')
var Sticky = Sticker.Stickyvar jsx = (
First Sticky
Contents
Second Sticky
Contents
Third Sticky
Contents
)
```When the Sticker container is scrolled such that the Sticky header reaches the top, the position of the Sticky element will be fixed (i.e. stuck) to the top of the screen. When the top of the second header hits the first header it will begin to push the first header out of the way, and then become sticky itself.
Multiple independent components will work as siblings but not if nested.
### Styling & Scrolling
If you set `useWindow={true}` react-sticker should work out of the box. Otherwise you will need to make your sticker container "scrollable" with css, e.g. ``