【问题标题】:CSSTransition animation not workingCSSTransition 动画不起作用
【发布时间】:2017-09-29 13:11:27
【问题描述】:

我有一个反应组件的动画,但我无法运行。

我认为过渡有问题,因为如果我只是制作不透明的动画,一切都可以正常工作

我正在使用来自react-transition-groupCSSTransitionGroup

<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;
 }

【问题讨论】:

  • 你能在 jsfiddle/jsbin/codepen 中提供一个工作示例吗?

标签: css css-transitions reactcsstransitiongroup


【解决方案1】:

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

另外,transition 属性应该设置在初始元素上,比如.animate-enter 而不是.animate-enter.animate-enter-active

【讨论】:

  • 我不确定是不是一样,但结果是一样的 :( 动画完成后会立即弹出框而不是动画
  • 您对过渡属性的看法是正确的。谢谢:)
猜你喜欢
  • 1970-01-01
  • 2019-01-14
  • 2023-03-08
  • 2020-02-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多