(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)]
; <https://gist.github.com/tibbon/6222633>
(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))
infinite scroll in a cell...