GiampaoloGabba / Xamarin.Plugin.SharedTransitions

Shared Element Transitions between pages in Xamarin.Forms (IOS/Android)
MIT License
414 stars 57 forks source link

Change Image.Source to some Url that has animation problem #25

Closed vulcanlee closed 4 years ago

vulcanlee commented 4 years ago

I download the TransitionApp sample App and upgrade all nuget package of this solution and change DogModel.Image value to Url, not local static image file.

When I run the sample project, the resulting animation path is a bit strange.

I have been recording (no sound) as following

https://vulcanfiles.blob.core.windows.net/$web/Share/2020/TransitionApp.mp4

May I set image.source property to Url?

GiampaoloGabba commented 4 years ago

The problem with setting an url is that the destination image is not yet downloaded when the transition start.

The shared transition works by getting the destination image size and position, and then animate the source image to that coordinates (this happens when pushing the new page).

If you use an url the image is just not here when needed, so you can't do a transition. You can mitigate this using a cache (for example ffimageloading) but first you have to populate it (meaning that the first call to that image will always be blank during a transition. Maybe you can just start an hidden task and start to download the image before the push).

I considered to try to download a remote image before the push, but this will slow down the navigation and make the app "clunky".

So my advice is to transition only local or prefetched images.

Btw i'm considering to mitigate this by adding a flag to animate the source image. So you'll need to specify a manual with & height for the destination (remote) image and the transition will occour. The quality will not be so great (expecialli if you are expanding the size) but better than nothing...