Fork me on GitHub
#hoplon
<
2018-03-25
>
thedavidmeister06:03:55

(ns infinite-scroll.javelin
 (:require
  hoplon.jquery
  [javelin.core :as j]))

(defn -infinite-scroll-cell
 ([] (-infinite-scroll-cell nil))
 ([threshold]
  (j/with-let [c (j/cell nil)]
   ; 
   (let [win (js/jQuery js/window)
         doc (js/jQuery js/document)
         threshold (or threshold 0)]
    (.on
     win
     (str "scroll." (gensym))
     (fn [e]
      (reset! c
       (<=
        (- (.height doc) threshold)
        (+ (.height win) (.scrollTop win))))))))))
(def infinite-scroll-cell (memoize -infinite-scroll-cell))

thedavidmeister07:03:09

infinite scroll in a cell...