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

moveTo()'s animation looks a little weird #188

Open
ln206 opened this issue Oct 21, 2020 · 4 comments
Open

moveTo()'s animation looks a little weird #188

ln206 opened this issue Oct 21, 2020 · 4 comments

Comments

@ln206
Copy link

ln206 commented Oct 21, 2020

How do I?

When I used moveTo(), the animation doesn't look linear. It looks like it was swirling for a bit. How do I get rid of this swirl effect? Is there a solution for this?

Version used

1.8.0

@markusressel
Copy link
Collaborator

Well not without a PR or a custom implementation on your end 😄
I think this is caused by the interaction of concurrent pan and zoom animations, and there is probably a solution that, but we haven't been able to tackle that yet. I'll leave this ticket open since I have noticed this myself for a long time now.

@markusressel
Copy link
Collaborator

This was already mentioned in #113, but went stale over time. I think it is a good idea to keep this open.

@markusressel
Copy link
Collaborator

markusressel commented Oct 27, 2020

I did a little digging.

Turns out the animation duration of the pan and zoom don't even align. When using some really long animation durations it becomes obvious that the pan animation finishes much quicker than the zoom animation, although the animatedFraction value of the animator is not all the way to 1 yet.

I did some testing, and - after almost losing all of my hair - I found that the PropertyValuesHolder.ofObject method (in internal fun animateUpdate(update: MatrixUpdate)) seems to do weird stuff, as it doesn't really behave like expected. Even when forcing a LinearInterpolator, the animation of the pan does not look linear (still looks kina accellerated), while the zoom does. I tried exchanging the pan property holder for two PropertyValuesHolder.ofFloat holders, and voila, the movement is indeed linear, and it also takes up the full animation duration, as expected.

Maybe I am not seeing something really obvious here and we just use the ofObject method wrong, but I would just ditch the ofObject method for now. Although even when applying this the moveTo animation is still a little weird at times, it doesn't do the strange wiggle anymore. The biggest issue I see is that it sometimes "bashes against the walls", which could probably be fixed by aligning the input coordinates with the boundaries of the current content size, or even simpler by allowing overpan temporarily during this animation. Also, the user defined animation duration is actually respected for both pan and zoom.

@Yahor10
Copy link

Yahor10 commented Oct 15, 2021

To be clear:
When i use image 512x512 and wanna zoom to Point (200,200);
First i zoomLayout.zoomTo(2.0);
Second` zoomLayout.panTo(-200),-200);
Or
I should use

`zoomLayout.panTo(-200 2.0,-2002.0); //2.0 becaouse of scale ?

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

No branches or pull requests

3 participants