Clean up node transition API

This commit is contained in:
Levi McCallum 2016-02-09 16:24:24 -08:00
parent 3444fa18dd
commit a00e9bb41c
3 changed files with 19 additions and 3 deletions

View File

@ -50,10 +50,18 @@
- (void)didCompleteLayoutTransition:(id<ASContextTransitioning>)context;
/**
* @abstract Invalidates the current layout and begins a relayout of the node to the new layout returned in `calculateLayoutThatFits:`.
* @abstract Transitions the current layout with a new constrained size.
*
* @discussion Animation is optional, but will still proceed through the `transitionLayout` methods with `isAnimated == NO`.
* @discussion Animation is optional, but will still proceed through your `animateLayoutTransition` implementation with `isAnimated == NO`.
* If the passed constrainedSize is the the same as the node's current constrained size, this method is noop.
*/
- (ASLayout *)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize animated:(BOOL)animated;
/**
* @abstract Invalidates the current layout and begins a relayout of the node with the current `constrainedSize`.
*
* @discussion Animation is optional, but will still proceed through your `animateLayoutTransition` implementation with `isAnimated == NO`.
*/
- (ASLayout *)transitionLayoutWithAnimation:(BOOL)animated;
@end

View File

@ -675,9 +675,14 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
return _pendingLayout;
}
- (ASLayout *)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize animated:(BOOL)animated
- (ASLayout *)transitionLayoutWithAnimation:(BOOL)animated
{
[self invalidateCalculatedLayout];
[self transitionLayoutWithSizeRange:_constrainedSize animated:animated];
}
- (ASLayout *)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize animated:(BOOL)animated
{
return [self measureWithSizeRange:constrainedSize completion:^{
_transitionContext = [[_ASTransitionContext alloc] initWithLayout:_pendingLayout
constrainedSize:constrainedSize

View File

@ -59,6 +59,9 @@
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[_node measureWithSizeRange:[self nodeConstrainedSize]];
_ensureDisplayed = YES;
[_node recursivelyFetchData];
}