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

feat(imagePreview): Added image preview ability to rotate images #13205

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

lzxiaoqi
Copy link
Contributor

Before submitting a pull request, please read the contributing guide.

在提交 pull request 之前,请阅读 贡献指南

#13153
上面issue中提到的ImagePreview组件增加图片的旋转功能
rotate

@codecov-commenter
Copy link

codecov-commenter commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 92.50000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 89.68%. Comparing base (e46ad73) to head (4dcb835).

Files with missing lines Patch % Lines
packages/vant/src/image-preview/ImagePreview.tsx 72.72% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13205      +/-   ##
==========================================
+ Coverage   89.64%   89.68%   +0.04%     
==========================================
  Files         257      257              
  Lines        7008     7045      +37     
  Branches     1733     1740       +7     
==========================================
+ Hits         6282     6318      +36     
+ Misses        382      381       -1     
- Partials      344      346       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@inottn
Copy link
Collaborator

inottn commented Nov 16, 2024

感谢你的 PR!这个功能的实现可能比表面看起来更复杂,需要注意以下几点:

  1. 在 ImagePreview 组件中,图片预览会根据图片的长宽比例以 contain 或 cover 的方式显示。旋转图片时,也应遵循这一规则。仅调整旋转角度可能会导致四周出现黑边,或图片超出可视区域的问题。
  2. 使用 matrix 替代 rotate 属性值,同时保留原注释,避免因 Safari 的内部优化问题导致元素不渲染。
  3. 新增的 rotate 和 rotateAngle 属性可能显得冗余,考虑是否可以合并为一个属性。

@lzxiaoqi
Copy link
Contributor Author

@inottn 您好 按照优化建议调整了下。看是否可行
rotate

@inottn
Copy link
Collaborator

inottn commented Nov 24, 2024

抱歉回复晚了。我查看了许多相关的应用后,觉得我们可以将旋转行为限定为 90 度,不支持其他角度。暂时没有想到用户需要非 90 度旋转的场景,这样的设计也能让代码更简洁。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants