File tree Expand file tree Collapse file tree 3 files changed +8
-9
lines changed
packages/component/src/ScrollToBottom Expand file tree Collapse file tree 3 files changed +8
-9
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 ,
Original file line number Diff line number Diff 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 ,
You can’t perform that action at this time.
0 commit comments