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

To get REAL center in graph.zoom you need to use window.innerWidth and window.innerHeight NOT graph.getViewPortCenterPoint() #5091

Open
Radomir-Drukh opened this issue Oct 26, 2023 · 3 comments
Labels
good first issue stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed

Comments

@Radomir-Drukh
Copy link

Describe the bug

To get REAL center in graph.zoom you need to use window.innerWidth and window.innerHeight NOT graph.getViewPortCenterPoint()

graph.zoom(1.2, graph.getViewPortCenterPoint()) - WRONG

This call will zoom with move with offset

graph.zoom(1.2, {x: window.innerWidth / 2, y: window.innerHeight / 2} ) - CORRECT

This call will zoom right at the center.

Please state this fact in the documentation

Your Example Website or App

Steps to Reproduce the Bug or Issue

  1. Create graph that takes up only part of the screen
  2. Call graph.zoom(1.2, graph.getViewPortCenterPoint())

Expected behavior

As a user, I expected that graph.zoom(1.2, graph.getViewPortCenterPoint()) will zoom at the center of the camera view but i am seeing strange offset

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome

Additional context

No response

@github-actions
Copy link

hi @Radomir-Drukh, welcome!

@github-actions
Copy link

Hi @Radomir-Drukh, Please star this repo if you find it useful! Thanks ⭐!
你好 @Radomir-Drukh。如果该仓库对你有用,可以 star 一下,感谢你的 ⭐!

@Yanyan-Wang
Copy link
Contributor

The implementation of getViewPortCenterPoint is:

image

Which means the API returns the point in rendering coordinate system for the center of canvas DOM. If the graph has initial zoom (1) and not translation, the point of rendering coordinate system is equal to the center point of canvas DOM in number. But after zooming and translating (maybe caused by fitView, fitCenter, mouse wheel, etc.), they are different. Refer to the doc: https://g6.antv.antgroup.com/en/manual/advanced/coordinate-system , where the rendering coordinate system I mentioned before is the pointX/pointY coordinate system in the doc.

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed
Projects
None yet
Development

No branches or pull requests

2 participants