[fractal] account: Reduce unwanted scrolling



commit 330bca114bd2d6a141e80f8a4971bf7d84d583ef
Author: Xiang Fan <sfanxiang gmail com>
Date:   Mon Feb 25 21:11:25 2019 +0800

    account: Reduce unwanted scrolling
    
    "size-allocate" signal can be triggered even when the revealer's state
    doesn't change, so we need to check if the revealer is actually
    revealing.
    
    The 'obvious' solutions for this don't work. If we connect to
    "child-revealed", the scroll only happens *after* expanding the
    revealer. If we connect to "reveal-child", we'll only scroll to the
    bottom at the beginning of the revealer's expansion, so the list will
    grow longer without scrolling.
    
    The handling is still imperfect though, since we always scroll to bottom
    regardless where the revealer is.

 fractal-gtk/src/app/connect/account.rs | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/fractal-gtk/src/app/connect/account.rs b/fractal-gtk/src/app/connect/account.rs
index f2e9da74..598aea92 100644
--- a/fractal-gtk/src/app/connect/account.rs
+++ b/fractal-gtk/src/app/connect/account.rs
@@ -291,16 +291,22 @@ impl App {
         let scroll = builder
             .get_object::<gtk::ScrolledWindow>("account_settings_scroll")
             .expect("Can't find account_settings_scroll in ui file.");
-        delete_revealer.connect_size_allocate(clone!(scroll => move |_, _| {
-            if let Some(adj) = scroll.get_vadjustment() {
-                let bottom = adj.get_upper() - adj.get_page_size();
-                adj.set_value(bottom);
+        delete_revealer.connect_size_allocate(clone!(scroll => move |this, _| {
+            if this.get_reveal_child() && !this.get_child_revealed() {
+                // The revealer is revealing
+                if let Some(adj) = scroll.get_vadjustment() {
+                    let bottom = adj.get_upper() - adj.get_page_size();
+                    adj.set_value(bottom);
+                }
             }
         }));
-        advanced_revealer.connect_size_allocate(clone!(scroll => move |_, _| {
-            if let Some(adj) = scroll.get_vadjustment() {
-                let bottom = adj.get_upper() - adj.get_page_size();
-                adj.set_value(bottom);
+        advanced_revealer.connect_size_allocate(clone!(scroll => move |this, _| {
+            if this.get_reveal_child() && !this.get_child_revealed() {
+                // The revealer is revealing
+                if let Some(adj) = scroll.get_vadjustment() {
+                    let bottom = adj.get_upper() - adj.get_page_size();
+                    adj.set_value(bottom);
+                }
             }
         }));
     }


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