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: fix tree node folding animation #3234

Merged
merged 1 commit into from
Jul 26, 2024

Conversation

li1615882553
Copy link
Contributor

@li1615882553 li1615882553 commented Jul 19, 2024

Types of changes

  • Bug fix
  • New feature
  • Enhancement
  • Component style change
  • Refactoring
  • Typescript definition change
  • Documentation change
  • Coding style change
  • Test cases
  • Continuous integration
  • Breaking change
  • Others

Background and context

Solution

修改树节点折叠动画不生效问题

修改前
树的展开折叠动画,只有展开动画生效,折叠动画失效
把动画时间调到了2s,方便查看效果:

Jul-19-2024.10-48-57.mp4

修改后
展开和折叠动画都生效,效果如下:

Jul-19-2024.16-54-26.mp4

产生原因
树产生动画的节点,无论展开折叠都是节点从无到有的过程,所以在before-enter回调中,获取到的scrollHeight都是0,这样折叠动画就是高度从0到0,所以动画失效

解决方案
不在before-enter中获取初始高度,统一改到enter中获取初始高度,强制浏览器回流后获取最终高度,使动画生效

How is the change tested?

Changelog

Component Changelog(CN) Changelog(EN) Related issues
tree 修复树折叠动画不生效问题 fix tree node folding animation

Checklist:

  • Test suite passes (npm run test)
  • Provide changelog for relevant changes (e.g. bug fixes and new features) if applicable.
  • Changes are submitted to the appropriate branch (e.g. features should be submitted to feature branch and others
    should be submitted to main branch)

Other information

Copy link

codesandbox bot commented Jul 19, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@xiangshu233
Copy link

@li1615882553 怎么感觉动画有点迟滞呢(第二个视频)

@li1615882553
Copy link
Contributor Author

@li1615882553 怎么感觉动画有点迟滞呢(第二个视频)

相对于原before-enter给初始高度来说,应该稍微有一点,调用enter的时候dom已经挂载了,而且在enter中还需要回流,才能使动画生效,也会有一定的消耗

@flsion flsion added the 🐛 Bug Something isn't working label Jul 26, 2024
@flsion flsion added this to the 2.56.0 milestone Jul 26, 2024
@flsion flsion merged commit 2e54ebd into arco-design:main Jul 26, 2024
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants