Skip to content

Instantly share code, notes, and snippets.

@martinklepsch
Last active June 1, 2021 14:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinklepsch/ff497c4dc5c484001cf4 to your computer and use it in GitHub Desktop.
Save martinklepsch/ff497c4dc5c484001cf4 to your computer and use it in GitHub Desktop.
(defn listen-file-drop
([el] (listen-file-drop el (chan)))
([el out & {:keys [concat]
:or {concat true}}]
(let [handler (events/FileDropHandler. el true)]
(events/listen el events/FileDropHandler.EventType.DROP
(fn [e] (let [files (event->files e)]
(.log js/console "dropped")
(.log js/console (-> (-source-event e) .-dataTransfer .-files prim-seq))
(if concat
(doseq [f files] (put! out f))
(put! out files))))))
out))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment