fix(accordion): Accordion组件默认开启的状态时 state wrapperHeight 初始设置为0会导致动画错误#1036
Open
leidenglai wants to merge 1 commit intojd-opensource:devfrom
Open
fix(accordion): Accordion组件默认开启的状态时 state wrapperHeight 初始设置为0会导致动画错误#1036leidenglai wants to merge 1 commit intojd-opensource:devfrom
leidenglai wants to merge 1 commit intojd-opensource:devfrom
Conversation
问题如果一个页面使用了两个以上 当第一个 当第一个 private toggleWithAnimation(): void {
const { open, isAnimation } = this.props
if (!this.isCompleted || !isAnimation) return
this.isCompleted = false
delayQuerySelector(this, '.at-accordion__body', 0).then(rect => {
const height = parseInt(rect[0].height.toString())
...
})
}建议可以在这里加一个动态 id: <View id="{uniqueDynamicID}" className='at-accordion__body'>{this.props.children}</View>然后在 delayQuerySelector(this, `#{uniqueDynamicID}.at-accordion__body`, 0).then(rect => {
const height = parseInt(rect[0].height.toString())
...
}) |
|
添加.at-accordion__content的height:auto !important 覆盖原本height,亲测有效 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wrapperHeight默认值 0时,toggleWithAnimation设置startHeight时 会导致css3错误触发动画;现在的示例第二个就有这个问题:https://taro-ui.jd.com/#/docs/accordion 。
fix: 将组件的state wrapperHeight 默认值设置为 ’unset‘,可以防止toggleWithAnimation方法设置初始高度是错误的出现动画。
希望采纳,或者用更优雅的方式解决下,谢谢