gpt4 book ai didi

css - (React) 带有 css 模块的 CSSTransition

转载 作者:行者123 更新时间:2023-12-04 11:22:02 25 4
gpt4 key购买 nike

我正在尝试在我的元素中实现一个模态的 CSSTransition。问题是我正在使用 css 模块。

我的模态渲染方法

render() {
return (
<Aux>
<Backdrop
show={this.props.show}
clicked={this.props.modalClosed}/>
<CSSTransition
in={this.props.show}
timeout={1000}
mountOnEnter
unmountOnExit
classNames={?}
>
<div
className={classes.Modal}
>
{this.props.children}
</div>
</CSSTransition>
</Aux>
)
}

我的 Modal.css
    .fade-enter {

}

.fade-enter-active {
animation:openModal 0.4s ease-out forwards;
}

.fade-exit{

}

.fade-exit-active{
animation: closeModal 0.4s ease-out forwards;
}

为了使其工作,我将什么传递给 CSSTransition 组件中的 classNames 属性?

最佳答案

JSX:

  <CSSTransition in={focused} timeout={500} classNames={{
enterActive: styles.MyClassEnterActive,
enterDone: styles.MyClassEnterDone,
exitActive: styles.MyClassExit,
exitDone: styles.MyClassExitActive
}}>
<span className={styles.MyClass}>animated</span>
</CSSTransition>

CSS 模块:
.MyClass {
position: absolute;
left: 5px;
}
.MyClassEnterActive {
left: 15px;
transition: left 500ms;
}
.MyClassEnterDone {
left: 15px;
}
.MyClassExit {
left: 15px;
}
.MyClassExitActive {
left: 5px;
transition: left 500ms;
}

谢谢 Lionel !

关于css - (React) 带有 css 模块的 CSSTransition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53912256/

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