提交 ba7f67ae 编写于 作者: R Rob Lourens

Settings editor - lazier paging when scrolling, looks nicer

上级 f704211f
......@@ -556,7 +556,7 @@ export class SettingsEditor2 extends BaseEditor {
private updateTreePagingByScroll(): void {
const lastVisibleElement = this.settingsTree.getLastVisibleElement();
if (lastVisibleElement && this.settingsTreeDataSource.pageTo(lastVisibleElement.index)) {
if (lastVisibleElement && this.settingsTreeDataSource.pageTo(lastVisibleElement.index, false)) {
this.renderTree();
}
}
......
......@@ -208,6 +208,7 @@ export class SettingsDataSource implements IDataSource {
export class SimplePagedDataSource implements IDataSource {
private static readonly SETTINGS_PER_PAGE = 30;
private static readonly BUFFER = 5;
private loadedToIndex: number;
......@@ -215,8 +216,10 @@ export class SimplePagedDataSource implements IDataSource {
this.loadedToIndex = SimplePagedDataSource.SETTINGS_PER_PAGE * 2;
}
pageTo(index: number): boolean {
if (index > this.loadedToIndex - SimplePagedDataSource.SETTINGS_PER_PAGE) {
pageTo(index: number, top = true): boolean {
const buffer = top ? SimplePagedDataSource.SETTINGS_PER_PAGE : SimplePagedDataSource.BUFFER;
if (index > this.loadedToIndex - buffer) {
this.loadedToIndex = (Math.ceil(index / SimplePagedDataSource.SETTINGS_PER_PAGE) + 1) * SimplePagedDataSource.SETTINGS_PER_PAGE;
return true;
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册