I'm using react transition group to handle animated CSSTransitions when a ponent is rendered. I want a simple fade in of a ponent.
The transition out seems to work properly, but the in transition does not.
If I put a debugger on the onEnter
property, I can see that the transition actually "should" work as expected. The enter-active state is triggered, the element starts at 0.1 opacity, and if I resume the debugger, the transition takes place.
But without the debugger, when the ponent renders, even though the enter-active
state is added to the ponent, it is just immediately visible - no opacity fade in occurs.
Here's my code:
<TransitionGroup ponent={null}>
{mobileSelectorsActive &&
<CSSTransition
classNames="anim_mobile_selectors"
timeout={5000}
//appear={true}
//mountOnEnter={true}
onEnter={()=>{
//debugger;
}}
>
<div>...</div>
</CSSTransition>
}
</TransitionGroup>
and the CSS:
.anim_mobile_selectors {
&-enter {
opacity: 0.1;
transition: opacity 5000ms linear;
}
&-enter-active, &-enter-done {
opacity:1;
}
&-exit {
opacity:1;
}
&-exit-active {
opacity: 0.1;
transition: opacity 5000ms linear;
}
}
I'm using react transition group to handle animated CSSTransitions when a ponent is rendered. I want a simple fade in of a ponent.
The transition out seems to work properly, but the in transition does not.
If I put a debugger on the onEnter
property, I can see that the transition actually "should" work as expected. The enter-active state is triggered, the element starts at 0.1 opacity, and if I resume the debugger, the transition takes place.
But without the debugger, when the ponent renders, even though the enter-active
state is added to the ponent, it is just immediately visible - no opacity fade in occurs.
Here's my code:
<TransitionGroup ponent={null}>
{mobileSelectorsActive &&
<CSSTransition
classNames="anim_mobile_selectors"
timeout={5000}
//appear={true}
//mountOnEnter={true}
onEnter={()=>{
//debugger;
}}
>
<div>...</div>
</CSSTransition>
}
</TransitionGroup>
and the CSS:
.anim_mobile_selectors {
&-enter {
opacity: 0.1;
transition: opacity 5000ms linear;
}
&-enter-active, &-enter-done {
opacity:1;
}
&-exit {
opacity:1;
}
&-exit-active {
opacity: 0.1;
transition: opacity 5000ms linear;
}
}
Share
Improve this question
asked May 15, 2019 at 22:24
mheaversmheavers
30.2k63 gold badges200 silver badges326 bronze badges
1 Answer
Reset to default 5This is a bit of a hack, but in case it helps anyone else, I solved this by shortening the transition in, and putting the animation on the "end" state:
//JSX
<CSSTransition
classNames="anim_mobile_selectors"
timeout={{
enter: 100,
exit: 500,
}}
><div>...</div>
</CSSTransition>
//CSS
.anim_mobile_selectors {
&-enter {
opacity: 0.01;
}
&-enter-active {
opacity: 0.01;
}
&-enter-done {
opacity:1;
transition: opacity 500ms linear;
}
&-exit {
opacity:1;
}
&-exit-active {
opacity: 0.01;
transition: opacity 500ms linear;
}
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744174533a4561692.html
评论列表(0条)