Skip to content

Commit

Permalink
fix: fix dumplicate caculate
Browse files Browse the repository at this point in the history
  • Loading branch information
zhbyak committed Apr 22, 2024
1 parent 7b2b545 commit 91dcd06
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/content/drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,23 @@ export default function PersistentDrawerRight() {

const handleResize = () => {
// 当窗口大小变化时,更新 width 的值
setDrawerWidth(caculateDrawerWidth());
setBackWidth(caculateBackWidth());
if (drawerWidth !== caculateDrawerWidth()) {
setDrawerWidth(caculateDrawerWidth());
}
if (backWidth !== caculateBackWidth()) {
setBackWidth(caculateBackWidth());
}
};

// 动态更新width
// React.useEffect(() => {
// const timer = setInterval(() => {
// handleResize();
// }, 1000);
// return () => {
// clearInterval(timer);
// };
// }, []);
React.useEffect(() => {
const timer = setInterval(() => {
handleResize();
}, 1000);
return () => {
clearInterval(timer);
};
}, []);

React.useEffect(() => {
// 添加窗口大小变化时的事件监听器
Expand Down

0 comments on commit 91dcd06

Please sign in to comment.