Forked from dvcrn/reagent-animated-example.cljs
Last active
September 19, 2018 16:52
-
-
Save briandunn/d68eb0e135b2459f5a53431d0ed0630f to your computer and use it in GitHub Desktop.
reagent react-native animation example
This file contains 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
;; very simple example on how to use Animated with reagent | |
;; https://facebook.github.io/react-native/docs/animations.html | |
(def animated (.-Animated js/React)) | |
(def animated-value (.-Value animated)) | |
(def animated-view (r/adapt-react-class (.-View animated))) | |
(defn bounce [] | |
(let [bounce-value (new animated-value 0)] | |
(.setValue bounce-value 1.5) | |
(-> bounce-value | |
(animated.spring #js {:toValue 0.8 :friction 1}) | |
(.start)) | |
(fn [] [animated-view | |
{:style {:flex 1 | |
:transform [{:scale bounce-value}] | |
:backgroundColor "red" | |
:borderRadius 10 | |
:margin 15 | |
:shadowColor "#000000" | |
:shadowOpacity 0.7 | |
:shadowRadius 2 | |
:shadowOffset {:height 1 :width 0}}} | |
[text {} "This is a test"]] ))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As it turns out, using create-class is not necessary for animation.