-
Notifications
You must be signed in to change notification settings - Fork 47.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flexible class names with CSSTransitionGroup #2680
Comments
This would be really useful for third party transition libraries (for example https://github.com/daneden/animate.css) |
+1 |
👍 using BEM, I usually end up with |
👍 would love to see this. |
An little more control over animation classes would be a nice addition to React. In addition to making animation libraries more accessible, this proposal makes it easier to reuse existing animation css that doesn't follow the -enter/-leave/-active naming convention. |
@nhagen Actually I tried to use Animate.CSS with it, while answering this SO question: Even with latest commit of @alexpien it does not work, because animate.css requires multiple classnames, like Thanks to @zpao's JsFiddle of latest build (currently 0.14.0-beta3), I was able to make a sandbox here: http://jsfiddle.net/ghmpo42k/6/ <ReactCSSTransitionGroup transitionName={{enter: "animated bounce", enterActive: "animated bounce", leave: "animated tada",leaveActive: "animated tada"}}>
{todos}
</ReactCSSTransitionGroup> This does not work, because:
I think this should be supported as well because currently it is not flexible enough to support all CSS animation frameworks. Also, when using only enter: "enter" / leave: "leave" parameters, I think we should keep it simple and only use "enter" and "leave", without the -active suffix. What I mean is that if we use:
(remember currently it does not work, so I give "pseudo outputs") We should not end up with something like:
but rather
|
We tried (with @schovi ) to add support for animating with multiple classes without breaking current API, but we were not sure how to approach the case when only When you pass more than just one CSS class to There are few options what to do:
We're not sure with this solution and we would like to open discussion about it. |
Allowing multiple class names like "animate bounce" would be perfect. |
Allowing multiple class names is also important for css-modules' (demo) |
👍 |
So we can't use css-modules with composition without that feature fixed? |
@ron23 you can use css-modules with composition elsewhere with React, just not with |
I'm a little confused. The documentation makes it seem as though it's already possible to achieve this: But as of 0.14.8, I still get the following errors if I try to pass the specified
|
Can you please provide a JSFiddle reproducing the issue? |
@gaearon nevermind, I think I got it working here: http://codepen.io/jokeyrhyme/pen/xVLXLK |
@gaearon figured it out. I was using CSS modules, but the classes were empty. I found that empty classes get optimised away, so the className string I was passing was |
What is the status of supporting multiple css classes? Is this a feature that is intended to be implemented? CSS based styling solutions is getting more and more popular see https://github.com/cssinjs/jss and https://github.com/callemall/material-ui is planning to switch over css classnames. I usually use one base css class and a user provided class for customizations. I like |
Are there any blocking issues for implementing multiple css classname support? |
I'd like to add a comment here to say that the transitionName, using an object, is very easily broken by not providing one of the "main" names (enter, leave, appear).
I should think that these classnames could be made optional by just checking if transitionName is a string or an object here: https://github.com/facebook/react/blob/master/src/addons/transitions/ReactCSSTransitionGroupChild.js#L66 |
thx @Nickman87, at least this helped me finding the cause for that misleading error message :) |
I was able to use animate.css with react. |
I’m going to close since we don’t plan any more changes to TransitionGroup in React repo. Instead, it now is maintained by the community, and you can file an issue in the new repository if this is still affecting you. Thanks! |
As of now, classes added to animated element is fixed based on transitionName.
Ex: if
transitionName="example"
,example-enter, example-enter-active, example-leave, example-leave-active
classes are added.Can we provide flexibility in naming classes ?
Ex: fadeIn for enter animation and fadeOut for leave animation
This will help us in using existing css animation libraries with react animation addon.
I propose the following API
adds
example-enter, example-enter-active, example-leave, example-leave-active
classes.adds
fadein, fadein-active, fadeout, fadeout-active
classesadds
fadein, fadeinActive, fadeout, fadeoutActive
classesThe text was updated successfully, but these errors were encountered: