[gnome-documents] When the size allocation changes, check whether whether the view isn't scrollable but has more books



commit c31208fdadf03d1597e5ac406292e5d04549d864
Author: IBBoard <dev ibboard co uk>
Date:   Thu Apr 25 20:28:34 2019 +0100

    When the size allocation changes, check whether whether the view
    isn't scrollable but has more books that could be loaded. If there
    are then increase the offset controller's offset to load more.
    
    This works whether the window is large when it opens or the user
    expands the window (either by dragging or maximising)
    
    Fixes #20 (copied from gnome-books#7 fix)

 src/overview.js | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/src/overview.js b/src/overview.js
index f6a86aa4..4dc60fae 100644
--- a/src/overview.js
+++ b/src/overview.js
@@ -776,6 +776,9 @@ const ViewContainer = new Lang.Class({
                           Lang.bind(this, this._onViewSelectionChanged));
         this.view.connect('notify::view-type',
                           Lang.bind(this, this._onViewTypeChanged));
+        this.view.connect('size_allocate',
+                          Lang.bind(this, this._onSizeAllocate));
+
 
         this._selectionModeAction = overview.getAction('selection-mode');
         this._selectionModeAction.connect('notify::state', Lang.bind(this, this._onSelectionModeChanged));
@@ -811,6 +814,19 @@ const ViewContainer = new Lang.Class({
             this._addListRenderers();
     },
 
+    _onSizeAllocate: function() {
+        let vadjustment = this.view.get_vadjustment();
+        let viewHeight = this.view.get_generic_view().get_allocation().height;
+        let scrollIsAtTop = vadjustment.value == 0;
+        let scrollMaxIsHeight = vadjustment.upper <= viewHeight;
+        let hasMoreDocuments = this._offsetController.getRemainingDocs() > 0;
+
+        if (scrollIsAtTop && scrollMaxIsHeight && hasMoreDocuments)
+        {
+            this._offsetController.increaseOffset();
+        }
+    },
+
     _getFirstDocument: function() {
         let doc = null;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]