Last active
June 1, 2021 14:54
-
-
Save martinklepsch/ff497c4dc5c484001cf4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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