فهرست منبع

[flutter]: animate opacity of scrollbar

appflowy 3 سال پیش
والد
کامیت
a7b306b59e
1فایلهای تغییر یافته به همراه8 افزوده شده و 10 حذف شده
  1. 8 10
      app_flowy/packages/flowy_infra_ui/lib/style_widget/scrolling/styled_scroll_bar.dart

+ 8 - 10
app_flowy/packages/flowy_infra_ui/lib/style_widget/scrolling/styled_scroll_bar.dart

@@ -45,7 +45,7 @@ class ScrollbarState extends State<StyledScrollbar> {
 
 
   @override
   @override
   void initState() {
   void initState() {
-    // widget.controller.addListener(() => setState(() {}));
+    widget.controller.addListener(() => setState(() {}));
     widget.controller.position.isScrollingNotifier.addListener(
     widget.controller.position.isScrollingNotifier.addListener(
       () {
       () {
         if (!mounted) {
         if (!mounted) {
@@ -55,16 +55,14 @@ class ScrollbarState extends State<StyledScrollbar> {
         if (!widget.controller.position.isScrollingNotifier.value) {
         if (!widget.controller.position.isScrollingNotifier.value) {
           // scroll is stopped
           // scroll is stopped
           _hideScrollbarOperation = CancelableOperation.fromFuture(
           _hideScrollbarOperation = CancelableOperation.fromFuture(
-            Future.delayed(const Duration(seconds: 2), () {
-              // Opti: hide with animation
-              hideHandler = true;
-              setState(() {});
-            }),
-          );
+            Future.delayed(const Duration(seconds: 2), () {}),
+          ).then((_) {
+            // Opti: hide with animation
+            hideHandler = true;
+            setState(() {});
+          });
         } else {
         } else {
-          // Do nothing
           hideHandler = false;
           hideHandler = false;
-          setState(() {});
         }
         }
       },
       },
     );
     );
@@ -175,7 +173,7 @@ class ScrollbarState extends State<StyledScrollbar> {
               ),
               ),
             ),
             ),
           )
           )
-        ]).opacity(showHandle ? 1.0 : 0.0, animate: false);
+        ]).opacity(showHandle ? 1.0 : 0.0, animate: true);
       },
       },
     );
     );
   }
   }