【发布时间】:2021-12-31 21:30:00
【问题描述】:
我正在使用 CSSTransition 组创建侧抽屉,它工作正常,但打开和关闭抽屉的时间延迟非常快。
import React from "react";
import ReactDOM from "react-dom";
import { CSSTransition } from "react-transition-group";
import "./SideDrawer.css";
const SideDrawer = (props) => {
const content = (
<CSSTransition
in={props.show}
timeout={300}
classNames="let"
unmountOnExit
mountOnEnter
>
<aside className="sidedrawer" onClick={props.onClick}>
{props.children}
</aside>
</CSSTransition>
);
return ReactDOM.createPortal(content, document.getElementById("drawer-hook"));
};
export default SideDrawer;
Sidedrawer.css
.sidedrawer {
position: fixed;
left: 0;
top: 0;
z-index: 100;
height: 100%;
width: 62%;
background: white;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26);
}
【问题讨论】:
-
你能分享一下 SideDrawer.css 文件吗
标签: reactjs css-transitions transition sidebar react-transition-group