Skip to content

fix(picker-view): round item height calculations#2544

Open
wangshunnn wants to merge 2 commits into
masterfrom
fix-picker-view-item-height
Open

fix(picker-view): round item height calculations#2544
wangshunnn wants to merge 2 commits into
masterfrom
fix-picker-view-item-height

Conversation

@wangshunnn

Copy link
Copy Markdown
Collaborator

Fix(RN)

修复 mpx2rn picker-view 多列滚动时选中项 Y 轴逐步偏移的问题。

主要改动:

  • 统一 picker-view-column 内部 item 渲染、padding、indicator、mask、snapToOffsets 与滚动计算的高度基准,避免 indicator-style.height 小数值和取整后的吸附高度不一致。
  • 初始化及更新 itemRawH 时统一取整,并通过 itemRawHRef + updateItemRawH 避免重复更新和高度回拉。
  • 将定时器 ref 类型从 NodeJS.Timeout 调整为 ReturnType<typeof setTimeout>,兼容 RN/runtime 类型环境。

nodeRef: scrollViewRef
})

const updateItemRawH = useCallback((height: number) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个封装没有必要,直接用setItemRawH本身内部的比较优化机制即可

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

已修复

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