@@ -169,20 +169,12 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
169
169
public scrollDiv = ( div : HTMLDivElement ) => {
170
170
if ( this . state . isAtBottom ) {
171
171
this . internalScrollCount += 1 ;
172
+ // Force auto here as smooth scrolling can be canceled by updates to the window
173
+ // from elsewhere (and keeping track of these would make this hard to maintain)
172
174
div . scrollIntoView ( { behavior : 'auto' , block : 'start' , inline : 'nearest' } ) ;
173
175
}
174
176
}
175
177
176
- public handleScroll = ( e : React . UIEvent < HTMLDivElement > ) => {
177
- if ( this . internalScrollCount > 0 ) {
178
- this . internalScrollCount -= 1 ;
179
- } else {
180
- this . setState ( {
181
- isAtBottom : e . currentTarget . scrollHeight - e . currentTarget . scrollTop === e . currentTarget . clientHeight
182
- } ) ;
183
- }
184
- }
185
-
186
178
// tslint:disable-next-line:no-any cyclomatic-complexity max-func-body-length
187
179
public handleMessage = ( msg : string , payload ?: any ) => {
188
180
switch ( msg ) {
@@ -287,6 +279,18 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
287
279
return false ;
288
280
}
289
281
282
+ private handleScroll = ( e : React . UIEvent < HTMLDivElement > ) => {
283
+ if ( this . internalScrollCount > 0 ) {
284
+ this . internalScrollCount -= 1 ;
285
+ } else {
286
+ const currentHeight = e . currentTarget . scrollHeight - e . currentTarget . scrollTop ;
287
+ const isAtBottom = currentHeight < e . currentTarget . clientHeight + 2 && currentHeight > e . currentTarget . clientHeight - 2 ;
288
+ this . setState ( {
289
+ isAtBottom
290
+ } ) ;
291
+ }
292
+ }
293
+
290
294
// Uncomment this to use for debugging messages. Add a call to this to stick in dummy sys info messages.
291
295
// private addDebugMessageCell(message: string) {
292
296
// const cell: ICell = {
0 commit comments