mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Avoid autoscrolling while user is scrolling
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
ebbc1abb85
commit
28581a3957
@ -47,11 +47,13 @@ export class PodLogList extends React.Component<Props> {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logs == prevProps.logs || !this.virtualListDiv.current) return;
|
if (logs == prevProps.logs || !this.virtualListDiv.current) return;
|
||||||
|
|
||||||
const newLogsLoaded = prevProps.logs.length < logs.length;
|
const newLogsLoaded = prevProps.logs.length < logs.length;
|
||||||
const scrolledToBeginning = this.virtualListDiv.current.scrollTop === 0;
|
const scrolledToBeginning = this.virtualListDiv.current.scrollTop === 0;
|
||||||
|
|
||||||
if (this.isLastLineVisible) {
|
if (this.isLastLineVisible || prevProps.logs.length == 0) {
|
||||||
this.scrollToBottom(); // Scroll down to keep user watching/reading experience
|
this.scrollToBottom(); // Scroll down to keep user watching/reading experience
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -129,7 +131,6 @@ export class PodLogList extends React.Component<Props> {
|
|||||||
@action
|
@action
|
||||||
scrollToBottom = () => {
|
scrollToBottom = () => {
|
||||||
if (!this.virtualListDiv.current) return;
|
if (!this.virtualListDiv.current) return;
|
||||||
this.isJumpButtonVisible = false;
|
|
||||||
this.virtualListDiv.current.scrollTop = this.virtualListDiv.current.scrollHeight;
|
this.virtualListDiv.current.scrollTop = this.virtualListDiv.current.scrollHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -137,7 +138,13 @@ export class PodLogList extends React.Component<Props> {
|
|||||||
this.virtualListRef.current.scrollToItem(index, align);
|
this.virtualListRef.current.scrollToItem(index, align);
|
||||||
};
|
};
|
||||||
|
|
||||||
onScroll = debounce((props: ListOnScrollProps) => {
|
onScroll = (props: ListOnScrollProps) => {
|
||||||
|
if (!this.virtualListDiv.current) return;
|
||||||
|
this.isLastLineVisible = false;
|
||||||
|
this.onScrollDebounced(props);
|
||||||
|
};
|
||||||
|
|
||||||
|
onScrollDebounced = debounce((props: ListOnScrollProps) => {
|
||||||
if (!this.virtualListDiv.current) return;
|
if (!this.virtualListDiv.current) return;
|
||||||
this.setButtonVisibility(props);
|
this.setButtonVisibility(props);
|
||||||
this.setLastLineVisibility(props);
|
this.setLastLineVisibility(props);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user