           (when (or crossed-forward crossed-backward)
             (let [direction (if crossed-forward :forward :backward)]
               (.log js/console "Passed" id "going" direction)
-              (when callback (callback direction)))))))))
+              (when-let [callback (:callback @options)]
+                (callback direction)))))))))
 
 (defn waypoint-context [_]
   (let [state (atom {})


(defn check-waypoints [last-scroll-y]
  (let [new-scroll-y (page-offset)]
    (doseq [[id {:keys [callback trigger-point]}] @waypoints]
      (when trigger-point
        (let [was-before-trigger (< last-scroll-y trigger-point)
              now-after-trigger (>= new-scroll-y trigger-point)

  (let [rect (.getBoundingClientRect node)]
    (+ (.-top rect) (.-pageYOffset js/window))))

(defn- make-reset-trigger-point [id options]
  (fn [this]
    (swap! waypoints assoc-in
           [id :trigger-point]
           (get-element-top (reagent/dom-node this)))))

(defn waypoint [child-el opts]
  (let [id (gensym "waypoint-id")
        options (atom opts)
        reset-trigger-point! (make-reset-trigger-point id options)]
    (reagent/create-class
     {:display-name "waypoint"

      :component-will-mount
      (fn []
        (swap! waypoints assoc id {:options options}))
      :component-will-unmount
      (fn []
        (swap! waypoints dissoc id))
