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

fix(image): Fixed issue 2266 (#2266) #2293

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

l123wx
Copy link
Contributor

@l123wx l123wx commented Jun 12, 2024

English Template / 英文模板

  • 我已阅读并遵循了贡献文档中的PR指南.

PR类型 (请至少选择一个)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Test Case
  • TypeScript definition update
  • Document improve
  • CI/CD improve
  • Branch sync
  • Other, please describe:

PR 描述

Fixes #2266

将 semi-foundation/image > handleMoveImage 方法内部分逻辑抽出来在 changeZoom 中复用

calcCanDragDirection 和 calcExtremeBounds 等方法中涉及到的 widht、height、containerWidth、containerHeight 改为参数传入,便于在不同时机复用。

更新日志

🇨🇳 Chinese

  • Fix: 修复鼠标滚轮缩放图片后,拖动了图片,再次缩放后会重置回中心位置的问题

🇺🇸 English

  • Fix: Fixed an issue where after the mouse wheel zoomed the picture, dragging the picture would reset to the center position after zooming again.

检查清单

  • 已增加测试用例或无须增加
  • 已补充文档或无须补充
  • Changelog已提供或无须提供

其他要求

  • 本条 PR 不需要纳入 Changelog

附加信息

Before

2024-06-12.17-35-33.mp4

After

2024-06-12.17-38-25.mp4

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 93e518d:

Sandbox Source
pr-story Configuration

@YyumeiZhang
Copy link
Collaborator

尝试了修改后的效果。
由于在 #1890 开始允许鼠标不在图片上也可以进行缩放操作,导致在修改后,如果鼠标不在图片上,开始放大图片,则一开始的缩放中心是页面中心,后面当图片逐渐放大,鼠标将出现在图片区域,缩放中心变成鼠标位置,视觉效果上有点问题。

缩放的时候同样如此,如果鼠标在图片上,一开始的缩小中心时鼠标位置,后面图片缩小,即使鼠标还在图片上,视觉上看看,缩放中心也变成了页面中心。

对于中心切换的问题,是否有更好的处理方式呢?🤔

@l123wx
Copy link
Contributor Author

l123wx commented Jun 27, 2024

尝试了修改后的效果。 由于在 #1890 开始允许鼠标不在图片上也可以进行缩放操作,导致在修改后,如果鼠标不在图片上,开始放大图片,则一开始的缩放中心是页面中心,后面当图片逐渐放大,鼠标将出现在图片区域,缩放中心变成鼠标位置,视觉效果上有点问题。

缩放的时候同样如此,如果鼠标在图片上,一开始的缩小中心时鼠标位置,后面图片缩小,即使鼠标还在图片上,视觉上看看,缩放中心也变成了页面中心。

对于中心切换的问题,是否有更好的处理方式呢?🤔

这个效果是在我的预期内的,个人感觉这样的方式也符合用户习惯,windows 的照片和微信的图片预览也是一样的缩放逻辑:

windows.mp4
default.mp4

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.

[Image] 鼠标滚轮缩放图片后,拖动了图片,再次缩放后会重置回中心位置
2 participants