]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
log viewer: add heuristic for scroll-direction dependent ratio distribution
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 24 Nov 2021 17:23:35 +0000 (18:23 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 24 Nov 2021 17:23:37 +0000 (18:23 +0100)
if the user scrolls down make 2/3 of the buffer load the downward
(newer) buffer and only 1/3 the upward (older), and vice versa, if
the user scrolls up load 2/3 of the older messages vs. 1/3 of newer
ones.

If the user scrolls around frantically we're roughly as good as
previously and in all other cases we're better now.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/panel/LogView.js

index eb7a17c253f72536422c09b0d93402a0391fca94..e52ec1275a42275c385cf53b9115176d3b314624 100644 (file)
@@ -7,7 +7,7 @@ Ext.define('Proxmox.panel.LogView', {
     extend: 'Ext.panel.Panel',
     xtype: 'proxmoxLogView',
 
-    pageSize: 500,
+    pageSize: 510,
     viewBuffer: 50,
     lineHeight: 16,
 
@@ -136,9 +136,13 @@ Ext.define('Proxmox.panel.LogView', {
            let limit = viewModel.get('params.limit');
            let total = viewModel.get('data.total');
 
+           // heuristic: scroll up? -> load more in front; scroll down? -> load more at end
+           let startRatio = view.lastTargetLine && view.lastTargetLine > targetLine ? 2/3 : 1/3;
+           view.lastTargetLine = targetLine;
+
            let newStart = scrolledToBottom
                ? Math.trunc(total - limit, 10)
-               : Math.trunc(targetLine - (limit / 2) + 10);
+               : Math.trunc(targetLine - (startRatio * limit) + 10);
 
            viewModel.set('params.start', Math.max(newStart, 0));
 
@@ -219,7 +223,7 @@ Ext.define('Proxmox.panel.LogView', {
            },
            params: {
                start: 0,
-               limit: 500,
+               limit: 510,
            },
        },
     },