Refactor autoscrolling code
This commit is contained in:
parent
d5aefa9b1d
commit
6276a76cbb
|
@ -227,7 +227,7 @@
|
||||||
(:filter-type item) ": " [:span.filter-item-string (:query item)]
|
(:filter-type item) ": " [:span.filter-item-string (:query item)]
|
||||||
[:span.icon-button [components/icon-remove]]]])
|
[:span.icon-button [components/icon-remove]]]])
|
||||||
@filter-items)]]
|
@filter-items)]]
|
||||||
[components/autoscroll-list {:class "panel-content-scrollable" :scroll? true}
|
[components/autoscroll-list {:class "panel-content-scrollable"}
|
||||||
[:table
|
[:table
|
||||||
{:style {:margin-bottom 10}
|
{:style {:margin-bottom 10}
|
||||||
:cell-spacing "0" :width "100%"}
|
:cell-spacing "0" :width "100%"}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
;; at-end?: element.scrollHeight - element.scrollTop === element.clientHeight
|
;; at-end?: element.scrollHeight - element.scrollTop === element.clientHeight
|
||||||
(> tolerance (- (.-scrollHeight el) (.-scrollTop el) (.-clientHeight el))))
|
(> tolerance (- (.-scrollHeight el) (.-scrollTop el) (.-clientHeight el))))
|
||||||
|
|
||||||
(defn autoscroll-list [{:keys [class scroll?] :as opts} childr]
|
(defn autoscroll-list [{:keys [class]} child]
|
||||||
(let [should-scroll (r/atom true)]
|
(let [should-scroll (r/atom true)]
|
||||||
(r/create-class
|
(r/create-class
|
||||||
{:display-name "autoscroll-list"
|
{:display-name "autoscroll-list"
|
||||||
|
@ -37,9 +37,8 @@
|
||||||
(reset! should-scroll (scrolled-to-end? n 100))))
|
(reset! should-scroll (scrolled-to-end? n 100))))
|
||||||
:component-did-update
|
:component-did-update
|
||||||
(fn [this]
|
(fn [this]
|
||||||
(let [scroll? (:scroll? (r/props this))
|
(let [n (r/dom-node this)]
|
||||||
n (r/dom-node this)]
|
(when @should-scroll
|
||||||
(when (and scroll? @should-scroll)
|
|
||||||
(scroll! n [0 (.-scrollTop n)] [0 (.-scrollHeight n)] 1600))))
|
(scroll! n [0 (.-scrollTop n)] [0 (.-scrollHeight n)] 1600))))
|
||||||
:reagent-render
|
:reagent-render
|
||||||
(fn [{:keys [class]} child]
|
(fn [{:keys [class]} child]
|
||||||
|
|
|
@ -95,7 +95,7 @@
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
#--re-frame-trace-- .panel-content-scrollable {
|
#--re-frame-trace-- .panel-content-scrollable {
|
||||||
margin: 10px;
|
margin: 0 0 10px 5px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue