mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
No trigger logs load when scrolled by method
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
7ac13f5004
commit
14e88a5bb6
@ -14,6 +14,7 @@ import { Button } from "../button";
|
|||||||
import { PodLogControls } from "./pod-log-controls";
|
import { PodLogControls } from "./pod-log-controls";
|
||||||
import { VirtualList } from "../virtual-list";
|
import { VirtualList } from "../virtual-list";
|
||||||
import { searchStore } from "./search.store";
|
import { searchStore } from "./search.store";
|
||||||
|
import { ListOnScrollProps } from "react-window";
|
||||||
import debounce from "lodash/debounce";
|
import debounce from "lodash/debounce";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -138,10 +139,11 @@ export class PodLogs extends React.Component<Props> {
|
|||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
onScroll = debounce(() => {
|
onScroll = debounce((props: ListOnScrollProps) => {
|
||||||
const toBottomOffset = 100 * lineHeight; // 100 lines * 18px (height of each line)
|
const toBottomOffset = 100 * lineHeight; // 100 lines * 18px (height of each line)
|
||||||
const { scrollHeight, clientHeight, scrollTop } = this.logsElement.current;
|
const { scrollHeight, clientHeight, scrollTop } = this.logsElement.current;
|
||||||
if (scrollTop === 0) {
|
// Trigger loading only if scrolled by user
|
||||||
|
if (scrollTop === 0 && !props.scrollUpdateWasRequested) {
|
||||||
this.loadMore();
|
this.loadMore();
|
||||||
}
|
}
|
||||||
if (scrollHeight - scrollTop > toBottomOffset) {
|
if (scrollHeight - scrollTop > toBottomOffset) {
|
||||||
@ -150,7 +152,7 @@ export class PodLogs extends React.Component<Props> {
|
|||||||
this.showJumpToBottom = false;
|
this.showJumpToBottom = false;
|
||||||
}
|
}
|
||||||
this.lastLineIsShown = clientHeight + scrollTop === scrollHeight;
|
this.lastLineIsShown = clientHeight + scrollTop === scrollHeight;
|
||||||
}, 300); // Debouncing to let virtual list do its internal works
|
}, 300); // Debouncing to let virtual list do its internal works
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function is called by VirtualList for rendering each of the row
|
* A function is called by VirtualList for rendering each of the row
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user