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 {
74
74
super ( props ) ;
75
75
this . _refresh = true ;
76
76
this . _ref = React . createRef ( ) ;
77
+ this . _scrolledToBottom = false ;
78
+ this . handleScroll = this . handleScroll . bind ( this ) ;
77
79
}
78
80
79
81
shouldComponentUpdate ( ) {
@@ -101,12 +103,26 @@ class LogOutput extends Component {
101
103
102
104
tailLogs ( ) {
103
105
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 ;
105
116
}
106
117
107
118
render ( ) {
108
119
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
+ >
110
126
< Text style = { logStyles . text } > { this . printLogs } </ Text >
111
127
</ ScrollView >
112
128
) ;
You can’t perform that action at this time.
0 commit comments