|
@@ -915,7 +915,7 @@
|
|
|
{:init (fn [state]
|
|
{:init (fn [state]
|
|
|
(assoc state
|
|
(assoc state
|
|
|
::ref (atom nil)
|
|
::ref (atom nil)
|
|
|
- ::height (atom 1)))
|
|
|
|
|
|
|
+ ::height (atom 100)))
|
|
|
:did-mount (fn [state]
|
|
:did-mount (fn [state]
|
|
|
(let [observer (js/ResizeObserver. (fn [entries]
|
|
(let [observer (js/ResizeObserver. (fn [entries]
|
|
|
(let [entry (first entries)
|
|
(let [entry (first entries)
|
|
@@ -925,17 +925,25 @@
|
|
|
(reset! *height height')))))]
|
|
(reset! *height height')))))]
|
|
|
(.observe observer @(::ref state)))
|
|
(.observe observer @(::ref state)))
|
|
|
state)}
|
|
state)}
|
|
|
- [state visible? content-fn loading-label]
|
|
|
|
|
|
|
+ [state visible? content-fn]
|
|
|
[:div.lazy-visibility {:ref #(reset! (::ref state) %)
|
|
[:div.lazy-visibility {:ref #(reset! (::ref state) %)
|
|
|
:style {:min-height @(::height state)}}
|
|
:style {:min-height @(::height state)}}
|
|
|
|
|
+
|
|
|
(if visible?
|
|
(if visible?
|
|
|
(when (fn? content-fn) (content-fn))
|
|
(when (fn? content-fn) (content-fn))
|
|
|
- (when loading-label [:span.text-sm.font-medium
|
|
|
|
|
- loading-label]))])
|
|
|
|
|
|
|
+ [:div.shadow.rounded-md.p-4.w-full.mx-auto
|
|
|
|
|
+ [:div.animate-pulse.flex.space-x-4
|
|
|
|
|
+ [:div.flex-1.space-y-3.py-1
|
|
|
|
|
+ [:div.h-2.bg-base-4.rounded]
|
|
|
|
|
+ [:div.space-y-3
|
|
|
|
|
+ [:div.grid.grid-cols-3.gap-4
|
|
|
|
|
+ [:div.h-2.bg-base-4.rounded.col-span-2]
|
|
|
|
|
+ [:div.h-2.bg-base-4.rounded.col-span-1]]
|
|
|
|
|
+ [:div.h-2.bg-base-4.rounded]]]]])])
|
|
|
|
|
|
|
|
(rum/defcs lazy-visible <
|
|
(rum/defcs lazy-visible <
|
|
|
(rum/local false ::visible?)
|
|
(rum/local false ::visible?)
|
|
|
- [state loading-label content-fn sensor-opts]
|
|
|
|
|
|
|
+ [state content-fn sensor-opts]
|
|
|
(let [*visible? (::visible? state)]
|
|
(let [*visible? (::visible? state)]
|
|
|
(visibility-sensor
|
|
(visibility-sensor
|
|
|
(merge
|
|
(merge
|
|
@@ -944,4 +952,4 @@
|
|
|
:offset {:top -300
|
|
:offset {:top -300
|
|
|
:bottom -300}}
|
|
:bottom -300}}
|
|
|
sensor-opts)
|
|
sensor-opts)
|
|
|
- (lazy-visible-inner @*visible? content-fn loading-label))))
|
|
|
|
|
|
|
+ (lazy-visible-inner @*visible? content-fn))))
|