css - React Transition Group : What is the difference between the appear, enter, exit 事件和enter, active done className后缀?

标签 css reactjs animation

为什么会有这么多变化?我记录了我的开发人员工具的元素选项卡,它似乎只有“-enter-done”和“-exit”类被应用于动画元素。

最佳答案

文档 explain it很容易:

CSSTransition applies a pair of class names during the appear, enter, and exit stages of the transition. The first class is applied and then a second "active" class in order to activate the css animation. After the animation, matching done class names are applied to persist the animation state.

所以出现、进入和退出是触发这些动画的不同情况。

出现 - 当您希望在组件首次挂载时进行转换(例如刷新页面时)。

Enter - 挂载新元素时的过渡。

退出 - 当元素卸载时。

后缀的作用是允许你在动画的每一步设置不同的CSS属性。

.my-animation-enter {
  opacity: 0;
  transition: opacity 1s ease;
}

.my-animation-enter-active {
  opacity: 1;
}

.my-animation-enter-done {
  cursor: pointer;
}

关于css - React Transition Group : What is the difference between the appear, enter, exit 事件和enter, active done className后缀?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50303048/

相关文章:

javascript - 如何在 react 中使用 console.log

iOS - UIView setCenter 在 UIView animateWithDuration 中不起作用

CSS 在页面加载时淡入,在悬停时淡出

html - 如何覆盖 Bootstrap 4 中的 nav-pills 下拉样式?

javascript - 如何让div在特定高度后淡入?

node.js - AWS Cognito 可以在 EB 上的 Node/Express/React 应用程序中使用吗?

iphone - 如何知道/测试动画何时播放完毕

jquery - 是否可以用文本而不是图像来重现这种效果?

html - 如何直接按 Tab 到子元素并忽略父元素

javascript - React,如何模拟用户输入进行单元测试?