Skip to content

Commit 6904040

Browse files
committed
docu(*): move examples to the top
1 parent 708feec commit 6904040

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

README.md

+36-36
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,32 @@ By default the component will be sticky when the top offset is reached and will
4848

4949
**Important**: To work properly the `Sticky` component must have a `StickyProvider` as a parent within its tree.
5050

51+
#### Example
52+
53+
``` javascript
54+
import * as React from 'react';
55+
import { Sticky } from 'react-stickup';
56+
57+
const container = React.createRef();
58+
59+
render(
60+
<StickyProvider>
61+
<div ref={container}>
62+
<Sticky container={container}>
63+
<Header>My Header</Header>
64+
</Sticky>
65+
<div style={{ height: '5000px' }}>
66+
Lots of content
67+
</div>
68+
</div>
69+
<Sticky>
70+
<Header>My Header</Header>
71+
</Sticky>
72+
</StickyProvider>,
73+
document.querySelector('main')
74+
);
75+
```
76+
5177
#### Properties
5278

5379
**`children?: React.ReactNode | ((options: { isSticky: boolean, isDockedToBottom: boolean, isNearToViewport: boolean }) => React.ReactNode)`**
@@ -86,16 +112,25 @@ Will be merged with generated styles of the placeholder element. It also allows
86112

87113
The class name is passed directly to the placeholder element.
88114

115+
### StickyScrollUp
116+
117+
Only Sticky to the top of the page in case it the page is scrolled up. When scrolled down, the content will just scroll out. `Sticky` next to the `StickyScrollUp` will stick to the bottom of it and will therefore not overlap.
118+
119+
**Important**: To work properly the `StickyScrollUp` component must have a `StickyProvider` as a parent within its tree. All `Sticky` components must be wrapped by the same instance of the `StickyProvider`as the `StickyScrollUp` component to not overlap.
120+
89121
#### Example
90122

91123
``` javascript
92124
import * as React from 'react';
93-
import { Sticky } from 'react-stickup';
125+
import { Sticky, StickyScrollUp, StickyProvider } from 'react-stickup';
94126

95127
const container = React.createRef();
96128

97129
render(
98130
<StickyProvider>
131+
<StickyScrollUp>
132+
My Stick up container
133+
</StickyScrollUp>
99134
<div ref={container}>
100135
<Sticky container={container}>
101136
<Header>My Header</Header>
@@ -104,20 +139,11 @@ render(
104139
Lots of content
105140
</div>
106141
</div>
107-
<Sticky>
108-
<Header>My Header</Header>
109-
</Sticky>
110142
</StickyProvider>,
111143
document.querySelector('main')
112144
);
113145
```
114146

115-
### StickyScrollUp
116-
117-
Only Sticky to the top of the page in case it the page is scrolled up. When scrolled down, the content will just scroll out. `Sticky` next to the `StickyScrollUp` will stick to the bottom of it and will therefore not overlap.
118-
119-
**Important**: To work properly the `StickyScrollUp` component must have a `StickyProvider` as a parent within its tree. All `Sticky` components must be wrapped by the same instance of the `StickyProvider`as the `StickyScrollUp` component to not overlap.
120-
121147
#### Properties
122148

123149
**`children?: React.ReactNode | ((options: { isSticky: boolean, isNearToViewport: boolean }) => React.ReactNode)`**
@@ -152,32 +178,6 @@ Will be merged with generated styles of the placeholder element. It also allows
152178

153179
The class name is passed directly to the placeholder element.
154180

155-
#### Example
156-
157-
``` javascript
158-
import * as React from 'react';
159-
import { Sticky, StickyScrollUp, StickyProvider } from 'react-stickup';
160-
161-
const container = React.createRef();
162-
163-
render(
164-
<StickyProvider>
165-
<StickyScrollUp>
166-
My Stick up container
167-
</StickyScrollUp>
168-
<div ref={container}>
169-
<Sticky container={container}>
170-
<Header>My Header</Header>
171-
</Sticky>
172-
<div style={{ height: '5000px' }}>
173-
Lots of content
174-
</div>
175-
</div>
176-
</StickyProvider>,
177-
document.querySelector('main')
178-
);
179-
```
180-
181181
## Contributing
182182

183183
Contributions are highly appreciated! The easiest is to fill an issue in case there is one before providing a PR so we can discuss the issue and a possible solution up front.

0 commit comments

Comments
 (0)