【发布时间】:2022-01-18 09:31:32
【问题描述】:
所以我尝试使用 react-transition-group 来为应用不同部分之间的过渡设置动画。
我在 CSSTransition 组件中有我想要动画的组件,方式如下:
return (
<CSSTransition in={showDepSearchResults} timeout={3000} classNames="fade" onEntered={() => showDepSearchResults(true)} onExit={() => showDepSearchResults(false)} >
<div className='searchResult' key='searchResult'>
<FlightSearchParameters flightSearchParams={flightSearchParams} typeOfDepartureDate={typeOfDepartureDate} typeOfReturnDate={typeOfReturnDate} typeOfTripSwitch={typeOfTripSwitch} formatPlaces={formatPlaces}/>
<h1>Vuelos {typeOfSearchTittle()} disponibles:</h1>
{showFlights()}
<button className='btn btn-secondary' onClick={(e) => handleSearchAgain(e)}>Buscar más vuelos</button>
</div>
</CSSTransition>
)
}
另外,我的 CSS 中有以下代码:
.fade-appear {
opacity: 0;
}
.fade-appear-active {
opacity: 1;
transition: opacity 3000ms;
}
.fade-enter {
opacity: 0;
}
.fade-enter-active {
opacity: 1;
transition: opacity 3000ms;
}
.fade-exit {
opacity: 1;
}
.fade-exit-active {
opacity: 0;
transition: opacity 3000ms;
}
由于某种原因,我还不明白这不起作用。 有人对此有答案吗?
完整代码在这里:https://github.com/coccagerman/bond
提前致谢!
【问题讨论】:
标签: reactjs animation react-transition-group web-animations react-animations