Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(CanlendarPicker): component freezes when the time interval is too… #6766

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

LLmoskk
Copy link

@LLmoskk LLmoskk commented Oct 24, 2024

component freezes when the time interval is too large, using virtual scrolling optimization
#6710 尝试修复此问题,使用了虚拟滚动避免 dom 数量过多引起的卡顿

Copy link
Contributor

github-actions bot commented Oct 24, 2024

Preview is ready

@@ -71,6 +71,8 @@
"rc-util": "^5.38.1",
"react-fast-compare": "^3.2.2",
"react-is": "^18.2.0",
"react-virtualized-auto-sizer": "^1.0.24",
"react-window": "^1.8.10",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看看能否使用 rc-virtual-list?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外,package lock 文件删一下

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外,package lock 文件删一下

好的收到 我尝试下 rc-virtual-list

// 遍历月份
const totalMonths = Math.ceil(maxDay.diff(minDay, 'months', true))
// default 每个月的高度是 344px
const monthHeight = 344
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个不一定的,如果 css var 改了会变

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMG 那改怎么修改, 虚拟滚动需要一个定高才行 o(╥﹏╥)o

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

哦我鸡道了,我这个变量初始是 344,然后初始化的时候统计计算一下用户设置的高度,再修改这个 monthHeight 的值,我还注意到renderDate这个 props 也会影响到高度,所以写死是不 ok 的,我尝试改一下

… large, using virtual scrolling optimization
@LLmoskk LLmoskk force-pushed the fix-CalendarPicker-virtualized branch from 8a3afca to b8a572a Compare October 24, 2024 13:24
@LLmoskk
Copy link
Author

LLmoskk commented Oct 25, 2024

@zombieJ 大佬我搞了个新版本解决用户自定义日历的话高度不可以固定写死值,整理了下之前的代码逻辑。思路是renderPlaceholderMonths 创建的 dom 放在组件里,然后获取到可被内容撑开 的 dom 元素,获取到他的高度也就是用户自定义后的高度后再告诉虚拟滚动 List 使用这个高度,测试方式我用src/components/calendar-picker/demos/demo3.less:91 文件修改了 height

@LLmoskk LLmoskk force-pushed the fix-CalendarPicker-virtualized branch from 69f1aed to 99bb852 Compare October 25, 2024 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants