Skip to content

Draggable with react draggable

Conor White-Sullivan edited this page Apr 29, 2017 · 2 revisions

Here's and example of how to pull in react components using cljsjs

In this case, I wanted have a component I could drag around, but only on a 25 x 25 pixel grid

(:require [reagent.core :as r]
   [cljsjs.react-draggable]
   [devcards.core :as dc :refer-macros [defcard-rg]])


(def draggable (r/adapt-react-class js/ReactDraggable))

(defn box []
  [draggable
   {:grid [25 25]}
   [:button {:style {:height "50px"
                     :width "50px"}} "hey"]])


(defcard-rg board
 [:div {:style {:height "500px"}}
          [box]
          [box]
          [box]
          ])

Clone this wiki locally