gpt4 book ai didi

CSSTransition 动画不工作

转载 作者:太空宇宙 更新时间:2023-11-04 08:08:04 27 4
gpt4 key购买 nike

我有一个 React 组件的动画,我无法运行它。

我认为过渡有问题,因为如果我只是一个不透明度的动画,一切都很好

我正在使用 react-transition-group 中的 CSSTransitionGroup

<CSSTransitionGroup
transitionName="animate"
transitionEnter={true}
transitionEnterTimeout={700}
transitionLeave={true}
transitionLeaveTimeout={700} >
{this.state.someState ? <Child key='animatedFormKey' handleChild={this.handleChild}/> : null}
</CSSTransitionGroup>

我的动画是这样的

.animate-enter {
transform: translate(0, 100%);

}

.animate-enter.animate-enter-active {
transform: translate(0%);
transition: transform 700ms ease-in-out;
}

以及它自身的组件样式

.childComponent {
position: fixed;
height: 77%;
width: 100%;
bottom: 0;
z-index: 12;
background-color: #fff;
}

最佳答案

这是一个猜测,基于代码并且没有尝试代码,因为你没有提供测试用例,但是 translate(A)translateX(A),与 translate(A, A) 不同。因此,您可能想在 .animate-enter.animate-enter-active 规则中尝试 transform: translate(0, 0);

此外,transition 属性应该在初始元素上设置,所以在 .animate-enter 上而不是在 .animate-enter.animate-enter-active 上。

关于CSSTransition 动画不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46489562/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com