Browse Source

fix: journals list scroll listener

charlie 5 years ago
parent
commit
849ad93937
2 changed files with 10 additions and 2 deletions
  1. 5 0
      src/main/frontend/components/sidebar.css
  2. 5 2
      src/main/frontend/ui.cljs

+ 5 - 0
src/main/frontend/components/sidebar.css

@@ -52,6 +52,7 @@
 .cp__sidebar-main-content {
   padding: 3rem 1.5rem;
   max-width: var(--ls-main-content-max-with);
+  min-height: 100vh;
   flex: 1;
 }
 
@@ -80,6 +81,10 @@
   background-color: var(--ls-secondary-background-color, #d8e1e8);
   padding-bottom: 48px;
 
+  &::-webkit-scrollbar {
+    display: none;
+  }
+
   &-inner {
     padding: 15px;
   }

+ 5 - 2
src/main/frontend/ui.cljs

@@ -209,6 +209,9 @@
    text])
 
 ;; scroll
+(defn get-doc-scroll-top []
+  (.-scrollTop js/document.documentElement))
+
 (defn main-node
   []
   (gdom/getElement "main-content"))
@@ -268,7 +271,7 @@
 ;; FIXME: compute the right scroll position when scrolling back to the top
 (defn on-scroll
   [on-load on-top-reached]
-  (let [node (main-node)
+  (let [node js/document.documentElement
         full-height (gobj/get node "scrollHeight")
         scroll-top (gobj/get node "scrollTop")
         client-height (gobj/get node "clientHeight")
@@ -286,7 +289,7 @@
         debounced-on-scroll (util/debounce 500 #(on-scroll
                                                  (:on-load opts) ; bottom reached
                                                  (:on-top-reached opts)))]
-    (mixins/listen state (main-node) :scroll debounced-on-scroll)))
+    (mixins/listen state js/document :scroll debounced-on-scroll)))
 
 (rum/defcs infinite-list <
   (mixins/event-mixin attach-listeners)