Last active
September 15, 2016 08:55
-
-
Save shaharz/10740986 to your computer and use it in GitHub Desktop.
React.js's CSSTransitionGroup in Om
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
(ns om-transition.core | |
(:require [om.core :as om :include-macros true] | |
[om.dom :as dom :include-macros true])) | |
(enable-console-print!) | |
(def ctg (aget js/React "addons" "CSSTransitionGroup")) | |
(def app-state (atom ["test"])) | |
(defn app [data owner] | |
(reify | |
om/IRender | |
(render [_] | |
(dom/div nil | |
(ctg (clj->js {:transitionName "example" | |
:children (map #(dom/h1 nil %) data)})) | |
(dom/button #js {:onClick #(om/transact! data (fn [v] (conj v "test")))} "+") | |
(dom/button #js {:onClick #(om/transact! data pop)} "-"))))) | |
(om/root | |
app | |
app-state | |
{:target (. js/document (getElementById "app"))}) |
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
<html> | |
<head> | |
<style> | |
.example-enter { | |
opacity: 0.01; | |
transition: opacity .5s ease-in; | |
} | |
.example-enter.example-enter-active { | |
opacity: 1; | |
} | |
.example-leave { | |
opacity: 1; | |
transition: opacity .5s ease-in; | |
} | |
.example-leave.example-leave-active { | |
opacity: 0.01; | |
} | |
</style> | |
<body> | |
<div id="app"></div> | |
<script src="http://fb.me/react-with-addons-0.9.0.js"></script> | |
<script src="out/goog/base.js" type="text/javascript"></script> | |
<script src="om_transition.js" type="text/javascript"></script> | |
<script type="text/javascript">goog.require("om_transition.core");</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment