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

how to pan to view so that it is in the center of the screen #6

Closed
sergeymild opened this issue Jul 10, 2020 · 0 comments
Closed

how to pan to view so that it is in the center of the screen #6

sergeymild opened this issue Jul 10, 2020 · 0 comments

Comments

@sergeymild
Copy link

sergeymild commented Jul 10, 2020

I have a zoomLayout with size width: 5000dp, height: 3000dp and one of view with size width: 100dp, height: 100dp and position x: 3000dp, y: 1500dp, i have tried engine.panTo and engine.panBy but it moves me to different places on different zoom.
for example: I have minZoom: 1f and maxZoom: 20f

if I set zoom 6.5f and pan to the view, then everything is fine; it is displayed in the center of the screen; if I set zoom 4f, the view is displayed closer to the upper left edge of the screen.
code than pan to view looks something like that:

val screenWidth = resources.displayMetrics.widthPixels
val screenHeight = resources.displayMetrics.heightPixels
val x = view.x - (screenWidth / 2 - view.width / 2)
val y = view.y - (screenHeight / 2 - view.height / 2)
engine.panTo(x = -x, y = -y, animated = true)
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

No branches or pull requests

1 participant