Skip to content

Commit ab886ef

Browse files
committed
Cleanup
1 parent 05afaf5 commit ab886ef

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ export default props =>
4545
| `atEnd` | `boolean` | `true` if the panel is currently near the end (see `mode` and `threshold` |
4646
| `atTop` | `boolean` | `true` if the panel is currently near top (see `threshold`) |
4747
| `mode` | `string` | `"bottom"` for scroll-to-bottom, `"top"` for scroll-to-top |
48-
| `scrollToBottom` | `function` | Call to scroll panel to bottom |
49-
| `scrollToEnd` | `function` | Call to scroll panel to end |
50-
| `scrollToTop` | `function` | Call to scroll panel to top |
48+
| `scrollTo` | `(scrollTop: number) => void` | Scroll panel to specified position |
49+
| `scrollToBottom` | `() => void` | Scroll panel to bottom |
50+
| `scrollToEnd` | `() => void` | Scroll panel to end |
51+
| `scrollToTop` | `() => void` | Scroll panel to top |
5152
| `threshold` | `number` | Threshold in pixels to consider the panel is near top/bottom, read-only and only set thru `props` |
5253

5354
# Contributions

packages/component/src/ScrollToBottom/Composer.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@ export default class ScrollToBottomComposer extends React.Component {
1818
atTop: true,
1919
mode: props.mode,
2020
handleUpdate: () => this.state.atEnd && this.state.scrollToEnd(),
21-
scrollToBottom: () => this.setState(state => ({
22-
scrollTop: state.target && (state.target.scrollHeight - state.target.offsetHeight)
23-
})),
21+
scrollTo: scrollTop => this.setState(() => ({ scrollTop })),
22+
scrollToBottom: () => this.state.scrollTo(this.state.target && (this.state.target.scrollHeight - this.state.target.offsetHeight)),
2423
scrollToEnd: () => this.state.mode === 'top' ? this.state.scrollToTop() : this.state.scrollToBottom(),
25-
scrollToTop: () => this.setState(state => ({
26-
scrollTop: 0
27-
})),
24+
scrollToTop: () => this.state.scrollTo(0),
2825
scrollTop: null,
2926
setTarget: target => this.setState(() => ({ target })),
3027
target: null,

packages/component/src/ScrollToBottom/Context.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default React.createContext({
66
atTop: true,
77
mode: 'bottom',
88
handleUpdate: () => 0,
9+
scrollTo: () => 0,
910
scrollToBottom: () => 0,
1011
scrollToEnd: () => 0,
1112
scrollToTop: () => 0,

0 commit comments

Comments
 (0)