|
@@ -13,6 +13,7 @@
|
|
|
(sel1 "ion-header")
|
|
(sel1 "ion-header")
|
|
|
(sel1 "#head")))
|
|
(sel1 "#head")))
|
|
|
|
|
|
|
|
|
|
+;; Notice this doesn't work on mobile
|
|
|
(defn- get-main-scroll-container
|
|
(defn- get-main-scroll-container
|
|
|
[]
|
|
[]
|
|
|
(sel1 "#main-content-container"))
|
|
(sel1 "#main-content-container"))
|
|
@@ -148,48 +149,6 @@
|
|
|
prop)
|
|
prop)
|
|
|
children]))
|
|
children]))
|
|
|
|
|
|
|
|
-;; FIXME: ux
|
|
|
|
|
-(defn- use-sticky-element!
|
|
|
|
|
- [^js/HTMLElement container target-ref]
|
|
|
|
|
- (hooks/use-effect!
|
|
|
|
|
- (fn []
|
|
|
|
|
- (let [^js el (rum/deref target-ref)
|
|
|
|
|
- ^js cls (.-classList el)
|
|
|
|
|
- *ticking? (volatile! false)
|
|
|
|
|
- el-top (-> el (.getBoundingClientRect) (.-top))
|
|
|
|
|
- head-top (-> (get-head-container) (js/getComputedStyle) (.-height) (js/parseInt))
|
|
|
|
|
- translate (fn [offset]
|
|
|
|
|
- (set! (. (.-style el) -transform) (str "translate3d(0, " offset "px , 0)"))
|
|
|
|
|
- (if (zero? offset)
|
|
|
|
|
- (.remove cls "translated")
|
|
|
|
|
- (.add cls "translated")))
|
|
|
|
|
- *last-offset (volatile! 0)
|
|
|
|
|
- handle (fn []
|
|
|
|
|
- (let [scroll-top (js/parseInt (.-scrollTop container))
|
|
|
|
|
- offset (if (> (+ scroll-top head-top) el-top)
|
|
|
|
|
- (+ (- scroll-top el-top) head-top 1) 0)
|
|
|
|
|
- offset (js/parseInt offset)
|
|
|
|
|
- last-offset @*last-offset]
|
|
|
|
|
- (if (and (not (zero? last-offset))
|
|
|
|
|
- (not= offset last-offset))
|
|
|
|
|
- (let [dir (if (neg? (- offset last-offset)) -1 1)]
|
|
|
|
|
- (loop [offset' (+ last-offset dir)]
|
|
|
|
|
- (translate offset')
|
|
|
|
|
- (if (and (not= offset offset')
|
|
|
|
|
- (< (abs (- offset offset')) 100))
|
|
|
|
|
- (recur (+ offset' dir))
|
|
|
|
|
- (translate offset))))
|
|
|
|
|
- (translate offset))
|
|
|
|
|
- (vreset! *last-offset offset)))
|
|
|
|
|
- handler (fn [^js e]
|
|
|
|
|
- (when (not @*ticking?)
|
|
|
|
|
- (js/window.requestAnimationFrame
|
|
|
|
|
- #(do (handle) (vreset! *ticking? false)))
|
|
|
|
|
- (vreset! *ticking? true)))]
|
|
|
|
|
- (.addEventListener container "scroll" handler)
|
|
|
|
|
- #(.removeEventListener container "scroll" handler)))
|
|
|
|
|
- []))
|
|
|
|
|
-
|
|
|
|
|
;; FIXME: another solution for the sticky header
|
|
;; FIXME: another solution for the sticky header
|
|
|
(defn- use-sticky-element2!
|
|
(defn- use-sticky-element2!
|
|
|
[^js/HTMLDivElement target-ref]
|
|
[^js/HTMLDivElement target-ref]
|
|
@@ -259,11 +218,16 @@
|
|
|
(.disconnect page-resize-observer))))))
|
|
(.disconnect page-resize-observer))))))
|
|
|
[]))
|
|
[]))
|
|
|
|
|
|
|
|
|
|
+(defn- mobile?
|
|
|
|
|
+ []
|
|
|
|
|
+ (when-let [user-agent js/navigator.userAgent]
|
|
|
|
|
+ (re-find #"Mobi" user-agent)))
|
|
|
|
|
+
|
|
|
(rum/defc table-header < rum/static
|
|
(rum/defc table-header < rum/static
|
|
|
[& prop-and-children]
|
|
[& prop-and-children]
|
|
|
(let [[prop children] (get-prop-and-children prop-and-children)
|
|
(let [[prop children] (get-prop-and-children prop-and-children)
|
|
|
el-ref (rum/use-ref nil)
|
|
el-ref (rum/use-ref nil)
|
|
|
- _ (use-sticky-element2! el-ref)]
|
|
|
|
|
|
|
+ _ (when-not (mobile?) (use-sticky-element2! el-ref))]
|
|
|
[:div.ls-table-header
|
|
[:div.ls-table-header
|
|
|
(merge {:class "border-y transition-colors bg-gray-01"
|
|
(merge {:class "border-y transition-colors bg-gray-01"
|
|
|
:ref el-ref
|
|
:ref el-ref
|