fix: 修正图片在iphone8下高度展示不对, scroll-view如果是设置flex的话展示异常 - #2510
Open
wangxiaokou wants to merge 6 commits into
Open
Conversation
wangxiaokou
commented
Jun 2, 2026
Collaborator
- 修正在iphone8下RNImage.getSize获取不到宽高的问题
- 修正在web下,如果给scroll-view设置display:flex 无法滚动的问题
hiyuki
reviewed
Jul 13, 2026
| const width = (source && source.width) || nativeEvent.width || 0 | ||
| const height = (source && source.height) || nativeEvent.height || 0 | ||
| // 布局模式下,若 getImageSize 没拿到尺寸(iPhone 8 返回 0,ratio 仍为 0),用真实尺寸兜底同步 view | ||
| if (isLayoutMode && width && height && !state.current.ratio) { |
Collaborator
There was a problem hiding this comment.
这里只是为了触发一下onLoad事件,为啥要加这堆逻辑?这堆逻辑在单独的getImageSize里有
hiyuki
reviewed
Jul 21, 2026
Collaborator
There was a problem hiding this comment.
有以下几个问题需要处理:
- [P1] 动态切换
src时可能永久沿用旧图片比例。 新增兜底受!state.current.ratio限制;第一张图片已经建立ratio后,如果切换到第二张图片且RNImage.getSize失败,即使第二张图的onLoad返回了正确宽高,也会跳过尺寸更新,widthFix、heightFix和裁剪模式会继续使用上一张图的比例。建议在src变化时重置对应尺寸状态,或者允许当前图片的onLoad尺寸覆盖旧状态,同时注意避免旧图片异步事件覆盖新图片状态。
Collaborator
|
该问题如果在image存在,理论上在view的background-image中也会存在 |
Collaborator
|
当前实现使用onLoad作为getImageSize失败的兜底,链路过长,可以改成并行获取,谁先获取到使用谁,未就绪时使用opacity: 0,而不是不挂载; 对于view+backgroundImage也采用相同方式修复改造 测试一下并行竞速情况下onload和getImageSize一般谁返回快 |
Collaborator
|
补充一个实现建议:当前方案以 建议注意以下实现边界:
整体链路可以收敛为: 这样既能避免依赖 |
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.