 
 (defn deg->rad [deg] (* deg 0.0174533))
 
-(declare radial-menu-button)
+
 
 (def motion-factory (React.createFactory js/ReactMotion.Motion))
 (def spring js/ReactMotion.spring)

         (is (= {:main-menu-item {:icon               "p"
                                  :db/id              0
                                  :sub-menu-item/list [{:icon  "c"
                                                        :db/id 1}]}}
                (db->tree (om/get-query RadialButtonMenu)
                          radial-menu-db radial-menu-db))))


                  depth
                  visible]} (om/get-computed this)
          {:keys [sub-menu-item/list icon]} (om/props this)
          child-diameter (/ diameter 1.5)
          [x y] (if visible end-position start-position)
          expanded (:expanded (om/get-state this))
          ]
      (dom/div (clj->js {:style {:position "absolute"}})
               [(map-indexed
                  (fn [index props]
                    (radial-button-menu
                      (om/computed
                        props
                        {:visible                 expanded
                         :toggle-expanded         toggle-expanded
                         :depth                   (inc depth)
                         :start-direction-degrees 0
                         :max-fan-angle-degrees   90
                         :fly-out-radius          (/ fly-out-radius 2)
                         :start-position          [(spring (+ diameter (* child-diameter 3.2)))
                                                   (spring (+ diameter (* child-diameter 3.2)))
                                                   ]
                         :end-position            (end-positions
                                                    index
                                                    child-diameter
                                                    start-direction-degrees
                                                    (/ max-fan-angle-degrees (dec (count list)))
                                                    fly-out-radius)
                         :diameter                child-diameter})))
                  list)
                (motion #js {:top  y
                             :left x}
                        (fn [res]
                          (dom/a (clj->js {:style                   {:position         "absolute"
                                                                     :WebkitUserSelect "none"
                                                                     :top              (aget res "top")
                                                                     :left             (aget res "left")
                                                                     :width            diameter
                                                                     :height           diameter
                                                                     :borderRadius     (/ diameter 2)
                                                                     :display          "flex"
                                                                     :justifyContent   "center"
                                                                     :alignItems       "center"}
                                           :dangerouslySetInnerHTML {:__html cljs-logo-svg}
                                           :onMouseDown             (fn [e]
                                                                      (.preventDefault e)
                                                                      (.stopPropagation e)
                                                                      (toggle-expanded this))})
                                 )))]))))

(def radial-button-menu (om/factory RadialButtonMenu {:keyfn :db/id}))

