Last active
January 12, 2017 11:47
-
-
Save pbaille/342e82365b28166f1ad7111029c2c641 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
(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