This repository was archived by the owner on Feb 23, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ class LogOutput extends Component {
7474 super ( props ) ;
7575 this . _refresh = true ;
7676 this . _ref = React . createRef ( ) ;
77+ this . _scrolledToBottom = false ;
7778 }
7879
7980 shouldComponentUpdate ( ) {
@@ -101,12 +102,17 @@ class LogOutput extends Component {
101102
102103 tailLogs ( ) {
103104 const view = this . _ref && this . _ref . current ;
104- view && view . scrollToEnd ( { animated : false } ) ;
105+ view && ! this . _scrolledToBottom && view . scrollToEnd ( { animated : false } ) ;
106+ }
107+
108+ handleScroll = ( { nativeEvent : { contentOffset, contentSize, layoutMeasurement } } ) => {
109+ const threshold = 10 ;
110+ this . _scrolledToBottom = ( layoutMeasurement . height + contentOffset . y + threshold ) >= contentSize . height ;
105111 }
106112
107113 render ( ) {
108114 return (
109- < ScrollView ref = { this . _ref } contentContainerStyle = { logStyles . content } >
115+ < ScrollView ref = { this . _ref } contentContainerStyle = { logStyles . content } onScroll = { this . handleScroll } scrollEventThrottle = { 16 } >
110116 < Text style = { logStyles . text } > { this . printLogs } </ Text >
111117 </ ScrollView >
112118 ) ;
You can’t perform that action at this time.
0 commit comments