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 +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,8 @@ class LogOutput extends Component {
7474 super ( props ) ;
7575 this . _refresh = true ;
7676 this . _ref = React . createRef ( ) ;
77+ this . _scrolledToBottom = false ;
78+ this . handleScroll = this . handleScroll . bind ( this ) ;
7779 }
7880
7981 shouldComponentUpdate ( ) {
@@ -101,12 +103,26 @@ class LogOutput extends Component {
101103
102104 tailLogs ( ) {
103105 const view = this . _ref && this . _ref . current ;
104- view && view . scrollToEnd ( { animated : false } ) ;
106+ view && ! this . _scrolledToBottom && view . scrollToEnd ( { animated : false } ) ;
107+ }
108+
109+ handleScroll ( {
110+ nativeEvent : { contentOffset, contentSize, layoutMeasurement } ,
111+ } ) {
112+ const threshold = 10 ;
113+ this . _scrolledToBottom =
114+ layoutMeasurement . height + contentOffset . y + threshold >=
115+ contentSize . height ;
105116 }
106117
107118 render ( ) {
108119 return (
109- < ScrollView ref = { this . _ref } contentContainerStyle = { logStyles . content } >
120+ < ScrollView
121+ ref = { this . _ref }
122+ contentContainerStyle = { logStyles . content }
123+ onScroll = { this . handleScroll }
124+ scrollEventThrottle = { 16 }
125+ >
110126 < Text style = { logStyles . text } > { this . printLogs } </ Text >
111127 </ ScrollView >
112128 ) ;
You can’t perform that action at this time.
0 commit comments