Skip to content

Instantly share code, notes, and snippets.

@jjttjj
Created August 8, 2012 15:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjttjj/3295977 to your computer and use it in GitHub Desktop.
Save jjttjj/3295977 to your computer and use it in GitHub Desktop.
(defn make-coll [x]
(cond
(coll? x) x
(nil? x) nil
:else (list x)))
(defn dragdrop [source-nodes target-nodes & {:keys [source-listeners target-listeners]}]
(let [source-group (goog.fx.DragDropGroup.)
target-group (goog.fx.DragDropGroup.)]
(doseq [source-node (make-coll source-nodes)]
(.addDragDropItem source-group (goog.fx.DragDropItem. source-node)))
(doseq [target-node (make-coll target-nodes)]
(.addDragDropItem target-group (goog.fx.DragDropItem. target-node)))
(.addTarget source-group target-group)
(.init source-group)
(doseq [[event handler] source-listeners]
(listen! source-group
event
handler))
(doseq [[event handler] target-listeners]
(listen! target-group
event
handler))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment