You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<td>Observe scroll position change by passing a callback function</td>
107
+
</tr>
102
108
<tr>
103
109
<td>State</td>
104
110
<td><code>useAnimating</code></td>
105
111
<td><code>() => [boolean]</code></td>
106
112
<td><code>true</code> if the panel is animating scroll effect</td>
107
113
</tr>
114
+
<tr>
115
+
<td>State</td>
116
+
<td><code>useAnimatingToEnd</code></td>
117
+
<td><code>boolean</code></td>
118
+
<td><code>true</code> if the panel is animating scroll effect and towards the end (depends on <code>mode</code>)</td>
119
+
</tr>
108
120
<tr>
109
121
<td>State</td>
110
122
<td><code>useAtBottom</code></td>
@@ -144,6 +156,8 @@ You can use React Hooks to perform various operations and signal state changes.
144
156
</tbody>
145
157
</table>
146
158
159
+
> Callback function passed to `useObserveScrollPosition` will be called rapidly during scrolling. To unsubscribe, pass a falsy value.
160
+
147
161
### Sample code
148
162
149
163
The following sample code will put a button inside the content view only if the view is not at the bottom. When the button is clicked, it will scroll the view to the bottom.
@@ -162,7 +176,7 @@ const Content = () => {
162
176
<p>Labore commodo consectetur commodo et Lorem mollit voluptate velit adipisicing proident sit. Dolor consequat nostrud aliquip ea anim enim. Culpa quis tempor et quis esse proident cupidatat reprehenderit laborum ullamco.</p>
163
177
<p>Incididunt labore nulla cupidatat occaecat elit esse occaecat culpa irure et nisi excepteur. Duis Lorem labore consectetur nostrud et voluptate culpa consequat enim reprehenderit. Id voluptate occaecat anim consequat id ea eiusmod laborum proident irure veniam esse. Aliquip nostrud culpa nostrud laborum cillum adipisicing dolore. Est tempor labore Lorem ad cupidatat reprehenderit exercitation pariatur officia ex adipisicing cupidatat exercitation.</p>
164
178
<p>Est labore cupidatat exercitation est laboris et tempor Lorem irure velit ea commodo sint officia. Ullamco exercitation cillum est fugiat do. Enim qui eu veniam nostrud tempor elit. Duis elit mollit ut reprehenderit sit adipisicing proident culpa veniam sint veniam consectetur fugiat Lorem. Sint dolor proident commodo proident non cupidatat labore.</p>
165
-
{!sticky &&<button onClick={scrollToBottom}>Click me to scroll to bottom</button>}
179
+
{!sticky &&<button onClick={scrollToBottom}>Click me to scroll to bottom</button>}
166
180
</React.Fragment>
167
181
);
168
182
}
@@ -176,7 +190,7 @@ export default () => (
176
190
177
191
## Context
178
192
179
-
> Starting with React Hooks, we are deprecating the React Context.
193
+
> Starting with React Hooks, we are deprecating the React Context. New functions may not be added to context.
180
194
181
195
We use 2 different contexts with different performance characteristics to provide better overall performance. [Function context](#function-context) contains immutable functions. [State context](#state-context) may change when the user scroll the panel.
182
196
@@ -194,40 +208,33 @@ This context contains functions used to manipulate the container. And will not u
<td>Observe scroll position change by passing a callback function</td>
200
-
</tr>
201
-
<tr>
202
-
<td><code>useScrollTo</code></td>
211
+
<td><code>scrollTo</code></td>
203
212
<td><code>(scrollTop: number | '100%') => void</code></td>
204
213
<td>Scroll panel to specified position</td>
205
214
</tr>
206
215
<tr>
207
-
<td><code>useScrollToBottom</code></td>
216
+
<td><code>scrollToBottom</code></td>
208
217
<td><code>() => void</code></td>
209
218
<td>Scroll panel to bottom</td>
210
219
</tr>
211
220
<tr>
212
-
<td><code>useScrollToEnd</code></td>
221
+
<td><code>scrollToEnd</code></td>
213
222
<td><code>() => void</code></td>
214
223
<td>Scroll panel to end (depends on <code>mode</code>)</td>
215
224
</tr>
216
225
<tr>
217
-
<td><code>useScrollToStart</code></td>
226
+
<td><code>scrollToStart</code></td>
218
227
<td><code>() => void</code></td>
219
228
<td>Scroll panel to start (depends on <code>mode</code>)</td>
220
229
</tr>
221
230
<tr>
222
-
<td><code>useScrollToTop</code></td>
231
+
<td><code>scrollToTop</code></td>
223
232
<td><code>() => void</code></td>
224
233
<td>Scroll panel to top</td>
225
234
</tr>
226
235
</tbody>
227
236
</table>
228
237
229
-
> Callback function passed to `useObserveScrollPosition` will be called rapidly during scrolling. To unsubscribe, pass a falsy value.
230
-
231
238
### State context
232
239
233
240
This context contains state of the container.
@@ -242,42 +249,42 @@ This context contains state of the container.
242
249
</thead>
243
250
<tbody>
244
251
<tr>
245
-
<td><code>useAnimating</code></td>
252
+
<td><code>animating</code></td>
246
253
<td><code>boolean</code></td>
247
254
<td><code>true</code> if the panel is animating scroll effect</td>
248
255
</tr>
249
256
<tr>
250
-
<td><code>useAnimatingToEnd</code></td>
257
+
<td><code>animatingToEnd</code></td>
251
258
<td><code>boolean</code></td>
252
259
<td><code>true</code> if the panel is animating scroll effect and towards the end (depends on <code>mode</code>)</td>
253
260
</tr>
254
261
<tr>
255
-
<td><code>useAtBottom</code></td>
262
+
<td><code>atBottom</code></td>
256
263
<td><code>boolean</code></td>
257
264
<td><code>true</code> if the panel is currently near bottom</td>
258
265
</tr>
259
266
<tr>
260
-
<td><code>useAtEnd</code></td>
267
+
<td><code>atEnd</code></td>
261
268
<td><code>boolean</code></td>
262
269
<td><code>true</code> if the panel is currently near the end (depends on <code>mode</code>)</td>
263
270
</tr>
264
271
<tr>
265
-
<td><code>useAtStart</code></td>
272
+
<td><code>atStart</code></td>
266
273
<td><code>boolean</code></td>
267
274
<td><code>true</code> if the panel is currently near the start (depends on <code>mode</code>)</td>
268
275
</tr>
269
276
<tr>
270
-
<td><code>useAtTop</code></td>
277
+
<td><code>atTop</code></td>
271
278
<td><code>boolean</code></td>
272
279
<td><code>true</code> if the panel is currently near top</td>
273
280
</tr>
274
281
<tr>
275
-
<td><code>useMode</code></td>
282
+
<td><code>mode</code></td>
276
283
<td><code>string</code></td>
277
284
<td><code>"bottom"</code> for scroll-to-bottom, <code>"top"</code> for scroll-to-top</td>
278
285
</tr>
279
286
<tr>
280
-
<td><code>useSticky</code></td>
287
+
<td><code>sticky</code></td>
281
288
<td><code>boolean</code></td>
282
289
<td><code>true</code> if the panel is sticking to the end</td>
283
290
</tr>
@@ -286,10 +293,44 @@ This context contains state of the container.
286
293
287
294
> `atEnd` and `sticky` are slightly different. During scroll animation, the panel is not at the end yet, but it is still sticky.
288
295
296
+
### Sample code
297
+
298
+
The following sample code will put a button inside the content view only if the view is not at the bottom. When the button is clicked, it will scroll the view to the bottom.
299
+
300
+
```jsx
301
+
importScrollToBottomfrom'react-scroll-to-bottom';
302
+
303
+
constContent= ({ scrollToBottom, sticky }) => {
304
+
return (
305
+
<React.Fragment>
306
+
<p>Labore commodo consectetur commodo et Lorem mollit voluptate velit adipisicing proident sit. Dolor consequat nostrud aliquip ea anim enim. Culpa quis tempor et quis esse proident cupidatat reprehenderit laborum ullamco.</p>
307
+
<p>Incididunt labore nulla cupidatat occaecat elit esse occaecat culpa irure et nisi excepteur. Duis Lorem labore consectetur nostrud et voluptate culpa consequat enim reprehenderit. Id voluptate occaecat anim consequat id ea eiusmod laborum proident irure veniam esse. Aliquip nostrud culpa nostrud laborum cillum adipisicing dolore. Est tempor labore Lorem ad cupidatat reprehenderit exercitation pariatur officia ex adipisicing cupidatat exercitation.</p>
308
+
<p>Est labore cupidatat exercitation est laboris et tempor Lorem irure velit ea commodo sint officia. Ullamco exercitation cillum est fugiat do. Enim qui eu veniam nostrud tempor elit. Duis elit mollit ut reprehenderit sit adipisicing proident culpa veniam sint veniam consectetur fugiat Lorem. Sint dolor proident commodo proident non cupidatat labore.</p>
309
+
{!sticky &&<button onClick={scrollToBottom}>Click me to scroll to bottom</button>}
0 commit comments