Skip to content

feat(ImageViewer): 支持视口之外图片向中心缩放#6406

Open
RSS1102 wants to merge 12 commits intodevelopfrom
rss1102/feat/image-viewer/drage
Open

feat(ImageViewer): 支持视口之外图片向中心缩放#6406
RSS1102 wants to merge 12 commits intodevelopfrom
rss1102/feat/image-viewer/drage

Conversation

@RSS1102
Copy link
Collaborator

@RSS1102 RSS1102 commented Feb 5, 2026

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

💡 需求背景和解决方案

📝 更新日志

  • 本条 PR 不需要纳入 Changelog

tdesign-vue-next

  • feat(ImageViewer): 支持蒙层拖拽和鼠标中心缩放

@tdesign-vue-next/chat

@tdesign-vue-next/auto-import-resolver

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

@tdesign-bot
Copy link
Collaborator

tdesign-bot commented Feb 5, 2026

TDesign Component Site Preview Open

Component Preview
tdesign-vue-next 完成
@tdesign-vue-next/chat 完成

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 5, 2026

  • tdesign-vue-next-demo

    npm i https://pkg.pr.new/@tdesign-vue-next/auto-import-resolver@6406
    
    npm i https://pkg.pr.new/tdesign-vue-next@6406
    
    npm i https://pkg.pr.new/@tdesign-vue-next/chat@6406
    

commit: 5d81777

@RSS1102 RSS1102 force-pushed the rss1102/feat/image-viewer/drage branch from dafcaf6 to 283853a Compare March 11, 2026 11:21
@RSS1102 RSS1102 force-pushed the rss1102/feat/image-viewer/drage branch from 283853a to 32eafae Compare March 12, 2026 09:32
@RSS1102 RSS1102 changed the title feat(ImageViewer): 支持蒙层拖拽和鼠标中心缩放 feat(ImageViewer): 支持视口之外图片向中心缩放 Mar 12, 2026
@RSS1102 RSS1102 requested a review from Copilot March 12, 2026 15:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the ImageViewer zoom/transform behavior by coordinating wheel zoom with the dragged image position, enabling a “converge back toward center when zooming out while overflowed” experience. It does this by exposing transform state from the image item to the parent viewer and extending the scale hook to optionally return updated translation offsets.

Changes:

  • Expose modalBoxRef / transform / resetTransform from TImageItem so the parent viewer can measure overflow and update translation during zoom.
  • Extend useScale to accept optional zoom-center/translate inputs and return a computed newTranslate for compensation.
  • Update image-viewer.tsx to detect overflow and adjust transform on wheel zoom-out, and to reset transforms on “reset”.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
packages/components/image-viewer/image-viewer.tsx Adds overflow detection and wheel zoom-out convergence logic; wires a ref to TImageItem and resets its transform on reset.
packages/components/image-viewer/hooks/index.ts Reworks scaling hook to optionally compute translation compensation and returns it to the caller; simplifies scale clamping.
packages/components/image-viewer/base/ImageItem.tsx Adds expose() of internal refs/state (modalBoxRef, transform, resetTransform) and attaches a DOM ref for measurements.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RSS1102 RSS1102 marked this pull request as ready for review March 14, 2026 08:54
@RSS1102 RSS1102 marked this pull request as draft March 16, 2026 02:10
@RSS1102 RSS1102 marked this pull request as ready for review March 16, 2026 02:47
@Wesley-0808 Wesley-0808 requested a review from Copilot March 16, 2026 03:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

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.

3 participants