Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Improve cell node relayout - #793

Merged
appleguy merged 5 commits into
facebookarchive:masterfrom
nguyenhuy:ImproveCellNodeRelayout
Nov 1, 2015
Merged

Improve cell node relayout#793
appleguy merged 5 commits into
facebookarchive:masterfrom
nguyenhuy:ImproveCellNodeRelayout

Conversation

@nguyenhuy

Copy link
Copy Markdown
Contributor

As discussed in #792:

@nguyenhuy
nguyenhuy force-pushed the ImproveCellNodeRelayout branch 2 times, most recently from f99b099 to 187549d Compare October 29, 2015 14:48
- Cell node automatically notifies the delegate after a relayout (via -setNeedsLayout) that results in a new size. Confirming to ASCellNodeDelegate; ASTableView and ASCollectionView reload the calling cell upon notifications. These views automatically set themselves as delegate of every node.
- The result is that ASCellNode subclasses don't need to manually notify the containing view. Thus, `-relayoutItemAtIndexPath` and `-relayoutRowAtIndexPath` are removed.
- Kittens example is updated to reflect the change.
@nguyenhuy
nguyenhuy force-pushed the ImproveCellNodeRelayout branch from 187549d to 5b8f7e9 Compare October 29, 2015 15:01

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the purpose of having a suggestedAnimation param when this is always automatic? How do you see this being extended?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It can be set to another value, by another object or in the subclass's initializer.

@Adlai-Holler

Copy link
Copy Markdown
Contributor

@nguyenhuy Does this mean cells will flash when they resize? In client apps I specifically avoid calling reloadRowsAtIndexPaths in favor of beginUpdates() / endUpdates() because UITableView seems to flash when reloading rows with animation no matter what you pass.

@nguyenhuy

Copy link
Copy Markdown
Contributor Author

@Adlai-Holler:

Does this mean cells will flash when they resize?

"Reload" destroys the existing node and loads a new one. "Relayout" (as in this PR) means the existing node is reused and only its layout is updated. This PR allows you to pass relayout animation (UITableViewRowAnimation) to a cell node, which will then be passed to ASTableView and the underlying UITableView (here). You can also animate the layout changes by wrapping -setNeedsLayout inside an animation block (like this).

In client apps I specifically avoid calling reloadRowsAtIndexPaths in favor of beginUpdates() / endUpdates() because UITableView seems to flash when reloading rows with animation no matter what you pass.

Yeah, that's because of the delete + insert behaviour. Though you can do some tricks to hide the flash like this, I would recommend avoiding reload methods, as discussed here.

If the delegate is an ASTableView, relayoutAnimation will still be considered for animation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's only safe to call from the background if the node isn't loaded, right? We should probably just remove that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in #812.

@appleguy

appleguy commented Nov 1, 2015

Copy link
Copy Markdown
Contributor

Thanks for the naming and formatting improvements. This is really a great change and reflects the development philosophy of ASDK, aiming for a smaller API surface that integrates functionality where it makes sense for the developer (e.g. ASCellNode itself bridging table and collection, layout being a concept that should extend to cells' height, etc)

appleguy added a commit that referenced this pull request Nov 1, 2015
ASCellNode delegate to automatically resize in table & collection when -setNeedsLayout called.
@appleguy
appleguy merged commit 0598935 into facebookarchive:master Nov 1, 2015
nguyenhuy added a commit to nguyenhuy/AsyncDisplayKit that referenced this pull request Nov 3, 2015
nguyenhuy added a commit to nguyenhuy/AsyncDisplayKit that referenced this pull request Nov 4, 2015
aimalygin pushed a commit to aimalygin/AsyncDisplayKit that referenced this pull request Feb 19, 2018
…r view is necessarily alive (has a superview). (facebookarchive#793)

* fix SIMULATE_WEB_RESPONSE not imported facebookarchive#449

* Fix to make rangeMode update in right time

* Keep collection/table node alive if view still in use.
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.

5 participants