Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@joelkuiper
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelkuiper/5f8de31f2a3bf69fdeab to your computer and use it in GitHub Desktop.
Save joelkuiper/5f8de31f2a3bf69fdeab to your computer and use it in GitHub Desktop.
Reagent + ReactCSSTransitionGroups
(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
}
[...]])]]))}))
.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;
}
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