Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pbaille
Last active January 12, 2017 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pbaille/342e82365b28166f1ad7111029c2c641 to your computer and use it in GitHub Desktop.
Save pbaille/342e82365b28166f1ad7111029c2c641 to your computer and use it in GitHub Desktop.
(require '[reagent.core :as r])
(defn i []
(let [dims (r/atom {})
this (atom nil)
resized? (atom nil)]
(fn [][:div
[:img {:src "http://www.lispcast.com/img/pre-conj/rich-hickey.jpeg"
:ref (fn [x] (reset! this x))
:on-load
(fn [x]
(when-not @resized?
(reset! dims {:width (.-width @this)
:height (.-height @this)})
(set! (.-width (.-style @this)) "100%")))}]
[:div (pr-str @dims)]])))
(r/render-component [i]
(js/document.getElementById "klipse-container"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment