fix: taro版 折叠面板增加一下动画控制,简化height计算
这个 PR 做了什么? (简要描述所做更改) taro版 折叠面板增加一下动画控制,简化height计算 这个 PR 是什么类型? (至少选择一个)
- [ ] feat: 新特性提交
- [ ] fix: bug 修复
- [ ] docs: 文档改进
- [ ] style: 组件样式/交互改进
- [ ] type: 类型定义更新
- [ ✅] perf: 性能、包体积优化
- [ ] refactor: 代码重构、代码风格优化
- [ ] test: 测试用例
- [ ] chore(deps): 依赖升级
- [ ] chore(demo): 演示代码改进
- [ ] chore(locale): 国际化改进
- [ ] chore: 其他改动(是关于什么的改动?)
这个 PR 涉及以下平台:
- [ ] NutUI H5 @nutui/nutui
- [✅] NutUI Taro @nutui/nutui-taro
这个 PR 是否已自测:
Summary by CodeRabbit
- 新功能
- 在折叠项中新增了
transition属性,以控制折叠时的过渡效果。
- 在折叠项中新增了
- 样式
- 添加了新的
.transitionCSS 类,以处理高度过渡效果。
- 添加了新的
Walkthrough
这些更改主要涉及为 collapse-item 组件引入 transition 属性,以控制元素折叠和展开时的过渡动画效果。同时,CSS 样式表中也新增了一个与过渡动画相关的选择器,进一步优化了组件的显示效果。
Changes
| 文件路径 | 更改摘要 |
|---|---|
src/packages/__VUE/collapseitem/collapse-item.taro.vue, collapse-item.vue |
添加了 transition 属性,并调整了内部逻辑以支持过渡动画。 |
src/packages/__VUE/collapseitem/index.scss |
添加了一个新的 .transition CSS 类选择器,以处理高度过渡效果的特定时间属性。 |
Sequence Diagram(s)
sequenceDiagram
participant User
participant CollapseItem
participant CSS
User->>CollapseItem: Click to toggle
CollapseItem-->>CSS: Apply/Remove .transition class
CollapseItem-->>CollapseItem: Check transition property
alt Transition is true
CollapseItem->>CSS: Apply height transition
else Transition is false
CollapseItem->>CSS: Apply instant height change
end
CollapseItem->>User: Toggle completed
Poem
小小折叠项,
过渡添新芳。
点击时伸展,
动效风姿扬。
变动皆自然,
设计巧思长。 🌸✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
增加 transition 属性,默认为 true,开发者自行控制是否有展开/收起动画。这个功能是可以添加的。
但是在 collapse-item.taro.vue 中将 auto 修改为 initial 有一些问题,修改之后会丢失展开/收起动画。
增加 transition 属性,默认为 true,开发者自行控制是否有展开/收起动画。这个功能是可以添加的。 但是在
collapse-item.taro.vue中将 auto 修改为 initial 有一些问题,修改之后会丢失展开/收起动画。
要的就是去掉这个动画,增加了一个配置,通过样式去设置,你没发现实际使用的时候这个动画会频繁重绘以及页面卡顿吗?
增加 transition 属性,默认为 true,开发者自行控制是否有展开/收起动画。这个功能是可以添加的。 但是在
collapse-item.taro.vue中将 auto 修改为 initial 有一些问题,修改之后会丢失展开/收起动画。
可以看下原先源代码里如何实现的这个动画。。他是不停的设置这个height....感谢提供框架,但是这个做法真的不好,可以参考重绘和重排
增加 transition 属性,默认为 true,开发者自行控制是否有展开/收起动画。这个功能是可以添加的。 但是在
collapse-item.taro.vue中将 auto 修改为 initial 有一些问题,修改之后会丢失展开/收起动画。可以看下原先源代码里如何实现的这个动画。。他是不停的设置这个height....感谢提供框架,但是这个做法真的不好,可以参考重绘和重排
并不存在「不停地设置 height」,在单次展开或者收起的操作过程中,都只会对 height 属性进行「两次修改」,目的是为了实现在高度上的平滑动画。
而且 PR 中的修改的结果是「一定没有动画」,而不是「用属性控制了是否启用动画」
增加 transition 属性,默认为 true,开发者自行控制是否有展开/收起动画。这个功能是可以添加的。 但是在
collapse-item.taro.vue中将 auto 修改为 initial 有一些问题,修改之后会丢失展开/收起动画。可以看下原先源代码里如何实现的这个动画。。他是不停的设置这个height....感谢提供框架,但是这个做法真的不好,可以参考重绘和重排
并不存在「不停地设置 height」,在单次展开或者收起的操作过程中,都只会对 height 属性进行「两次修改」,目的是为了实现在高度上的平滑动画。
而且 PR 中的修改的结果是「一定没有动画」,而不是「用属性控制了是否启用动画」 1.老兄,你用微信小程序模拟器选择下这个元素,你看下呢,他的hegit是在变的, 2.pr里面接收外部props transition: boolean .... 有值得的时候会有类名的
1、审查元素时 height 当然会变化,因为本身实现的效果就是关于 height 的动画。而且对高度做两次修改也是很常见的做法。 2、增加开关没毛病。但是把 auto 改成 initial 是不合理的,这样修改之后,即使设置为 true,也不存在动画。
1、审查元素时 height 当然会变化,因为本身实现的效果就是关于 height 的动画。而且对高度做两次修改也是很常见的做法。 2、增加开关没毛病。但是把 auto 改成 initial 是不合理的,这样修改之后,即使设置为 true,也不存在动画。
问题就是出在这里啊,原先的动画效果是不停地改变heigt的值 transition: height 0.3s ease-in-out; 这个效果就是我说的频繁更新height的地方,动画要避免操作这类导致重排的属性,我只是需要满足能控制是否有动画就行了
就是不改,非要保留这个height 操作...