ZoomLayout icon indicating copy to clipboard operation
ZoomLayout copied to clipboard

moveTo()'s animation looks a little weird

Open ln206 opened this issue 4 years ago • 4 comments

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

ln206 avatar Oct 21 '20 08:10 ln206

Well not without a PR or a custom implementation on your end :smile: 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 avatar Oct 21 '20 16:10 markusressel

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

markusressel avatar Oct 21 '20 16:10 markusressel

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.

markusressel avatar Oct 27 '20 09:10 markusressel

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 ?

Yahor10 avatar Oct 15 '21 17:10 Yahor10