Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

support animation between two layouts #12

Merged
merged 3 commits into from
Jul 18, 2016
Merged

support animation between two layouts #12

merged 3 commits into from
Jul 18, 2016

Conversation

nicksnyder
Copy link
Collaborator

No description provided.

@nicksnyder nicksnyder added this to the 2.0 milestone Jul 5, 2016
view.frame = frame
// If we are preparing an animation, then we don't want to update frames or configure views.
if let view = layout.makeView(from: recycler, configure: !prepareAnimation) {
if !prepareAnimation {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there are conceptually two tree walks here, one to create or update the sub/superview tree and another to set the frames and other configured properties. Sometimes we want to run them together and sometimes separately. Perhaps this logic would be cleaner as separate functions instead of passing down the flag throughout?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is certainly possible to do this in two passes, but I think the code would be more complicated due to view collapsing. It is nice that we can do it incrementally, e.g.:

if !prepareAnimation {
    for subview in subviews {
        subview.frame.offsetInPlace(dx: frame.origin.x, dy: frame.origin.y)
    }
}

@nicksnyder nicksnyder force-pushed the animate branch 3 times, most recently from ee80fb1 to 85174ac Compare July 14, 2016 17:56

## Requirements

1. Use the `tag` parameter to identify layouts involved in the animation.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename tag to id


/**
An identifier for the layout.
It is used to identify which views should be reused when animating from one layout to another.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a bit more detail here, talking about how applying two layouts reuses views by this id. Maybe even rename it to viewReuseId?

Also somewhere we should describe what happens if there is a duplicate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

viewId

@nicksnyder
Copy link
Collaborator Author

Going to merge this into master. This is probably not the final API since we want to do #24 before releasing 2.0.

@nicksnyder nicksnyder merged commit ace6ce9 into master Jul 18, 2016
@nicksnyder nicksnyder deleted the animate branch July 18, 2016 18:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants