Last active
August 29, 2015 14:22
-
-
Save joelkuiper/5f8de31f2a3bf69fdeab to your computer and use it in GitHub Desktop.
Reagent + ReactCSSTransitionGroups
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
(def css-transition-group | |
(reagent/adapt-react-class js/React.addons.CSSTransitionGroup)) | |
(defn popup | |
[app-state] | |
(reagent/create-class | |
{:reagent-render | |
(fn [app-state] | |
(let [popup-state @state | |
visible? (:visible popup-state)] | |
[:div | |
[css-transition-group {:transition-name "zoom"} ; name it after your css transition | |
(when visible? | |
[:div.animated.zoom-in | |
{:key "popup" ; key is important | |
} | |
[...]])]]))})) |
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
.animated { | |
-webkit-animation-duration: 0.125s; | |
animation-duration: 0.125s; | |
-webkit-animation-fill-mode: both; | |
animation-fill-mode: both; | |
-webkit-backface-visibility: hidden; | |
-moz-backface-visibility: hidden; | |
-ms-backface-visibility: hidden; | |
backface-visibility: hidden; | |
} | |
@-webkit-keyframes zoom-enter { | |
0% { | |
opacity: 0; | |
-webkit-transform: scale3d(.3, .3, .3); | |
transform: scale3d(.3, .3, .3); | |
} | |
100% { | |
opacity: 0.99; | |
} | |
} | |
@keyframes zoom-enter { | |
0% { | |
opacity: 0; | |
-webkit-transform: scale3d(.3, .3, .3); | |
transform: scale3d(.3, .3, .3); | |
} | |
100% { | |
opacity: 0.99; | |
} | |
} | |
.zoom-enter { | |
-webkit-animation-name: zoom-enter; | |
animation-name: zoom-enter; | |
} | |
.zoom-enter.zoom-enter-active { | |
opacity: 1.0; | |
} | |
@-webkit-keyframes zoom-leave { | |
0% { | |
opacity: 1; | |
} | |
100% { | |
opacity: 0.01; | |
-webkit-transform: scale3d(.3, .3, .3); | |
transform: scale3d(.3, .3, .3); | |
} | |
} | |
@keyframes zoom-leave { | |
0% { | |
opacity: 1; | |
} | |
100% { | |
opacity: 0.01; | |
-webkit-transform: scale3d(.3, .3, .3); | |
transform: scale3d(.3, .3, .3); | |
} | |
} | |
.zoom-leave { | |
-webkit-animation-name: zoom-leave; | |
animation-name: zoom-leave; | |
} | |
.zoom-leave.zoom-leave-active { | |
opacity: 0; | |
} |
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
Be sure to include react-with-addons in your profile.clj | |
``` | |
[reagent "0.5.0" :exclusions [cljsjs/react]] | |
[cljsjs/react-with-addons "0.13.1-0"] | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment