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

Drawing bug with useGlobalCoordinateSpace #85

Closed
adellibovi opened this issue Feb 11, 2017 · 7 comments
Closed

Drawing bug with useGlobalCoordinateSpace #85

adellibovi opened this issue Feb 11, 2017 · 7 comments

Comments

@adellibovi
Copy link

HI Luke,

When using .useGlobalCoordinateSpace the animations get wrong on dismissing.
Video for reference: https://cl.ly/3e2S3n1k0V15

Looking at the view hierarchy I found what it may be wrong.
Infact, with .useGlobalCoordinateSpace the three white views appear to be before the background view (which is the highlighted row)
screen shot 2017-02-11 at 19 32 56

Instead without the .useGlobalCoordinateSpace I get the white cards views inside the background view.
screen shot 2017-02-11 at 19 30 57

I understand that in the case of .useGlobalCoordinateSpace not having the views inside the backgroundView is something expected, since we want to animated them separately.
But maybe the background view should appear before the three views? Thoughts?

I'll try to recreate the example ASAP

@lkzhao
Copy link
Collaborator

lkzhao commented Feb 11, 2017

Hey Alfredo, after looking at it. I noticed that this won't be a easy fix. Currently, Hero inserts all source views first then destination views. Before inserting a destination view, it check if there is a matched source view, and bring that source view to the front of the view hierarchy.

In your case, let say the first VC is A, and second VC is B.
When dismissing from B to A, source VC is B, and destination VC is A.
When Hero is inserting the A's blue card view, it sees that there is a matched view from B. Therefore pulling that matched view from B up the view hierarchy. Hence, covered your white views.

To solve this, Hero will need to know which views need to go above certain views, a dependency system of some sort. And when pulling the source view up, Hero needs to pull all the views that are dependent on the source view. That is what I have in mind, but seems hard to implement. I don't know if you have any better ideas.

I will try to come up with something next week, for now just set the zPosition of the white views. You can use the new beginWith modifier to set the zPosition during the transition:

.beginWith(modifiers:[.zPosition(5)])

This sets the zPosition directly on the snapshot's layer during the animation without animating it.

On a side note, your card example looks awesome! I am updating the README graphics, do you mind if I build something similar to what you have as an example in the README?

@adellibovi
Copy link
Author

Understand, I'll think about it in the next days. Maybe a dependency system with a graph structure wouldn't be too hard, but it definitely require work. Do you think that is something you would like to have for Hero? If so I may want to prepare a PR and/or draft for you.

About the example thing, do you mind if you try to replicate differently? For example a different form for the card, i.e. squared with a different colour. The app is not live yet and this interaction is a main part of the app, so for sure you can replicate it, I'll appreciate if it will be distinct :)

@lkzhao
Copy link
Collaborator

lkzhao commented Feb 12, 2017 via email

@adellibovi
Copy link
Author

Sure, give me a sec 👍

@adellibovi
Copy link
Author

Come on man!!! It worked 💯 Very well done, how you did at the end?

@adellibovi
Copy link
Author

Just saw the commit, thanks!
A question, do you plan to have starter tasks for this project? I really would like to help more :)

@lkzhao
Copy link
Collaborator

lkzhao commented Feb 12, 2017

When pulling the source view up, I do a recursive search for subviews and sibling views that might be a dependent. But I am not entirely satisfied with this implementation. If there is a inserted destination view that depend on one of the source view, it won't be pull up. When this happens, the source view will cover that destination view. I have another implementation in mind that might be better. Will try to implement it in a few days.

I will put up a todo list in the projects tab later day. Glad that you are willing to help!

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

2 participants