Implement async transition

This commit is contained in:
Huy Nguyen
2016-03-08 23:30:03 -08:00
parent cdd1bd1e39
commit fa8f2f4429
12 changed files with 544 additions and 233 deletions

View File

@@ -127,20 +127,38 @@
[self didRelayoutFromOldSize:oldSize toNewSize:self.calculatedSize];
}
- (ASLayout *)transitionLayoutWithAnimation:(BOOL)animated
- (void)transitionLayoutWithAnimation:(BOOL)animated
shouldMeasureAsync:(BOOL)shouldMeasureAsync
measurementCompletion:(void(^)())completion
{
CGSize oldSize = self.calculatedSize;
ASLayout *layout = [super transitionLayoutWithAnimation:animated];
[self didRelayoutFromOldSize:oldSize toNewSize:layout.size];
return layout;
[super transitionLayoutWithAnimation:animated
shouldMeasureAsync:shouldMeasureAsync
measurementCompletion:^{
[self didRelayoutFromOldSize:oldSize toNewSize:self.calculatedSize];
if (completion) {
completion();
}
}
];
}
- (ASLayout *)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize animated:(BOOL)animated
- (void)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize
animated:(BOOL)animated
shouldMeasureAsync:(BOOL)shouldMeasureAsync
measurementCompletion:(void(^)())completion
{
CGSize oldSize = self.calculatedSize;
ASLayout *layout = [super transitionLayoutWithSizeRange:constrainedSize animated:animated];
[self didRelayoutFromOldSize:oldSize toNewSize:layout.size];
return layout;
[super transitionLayoutWithSizeRange:constrainedSize
animated:animated
shouldMeasureAsync:shouldMeasureAsync
measurementCompletion:^{
[self didRelayoutFromOldSize:oldSize toNewSize:self.calculatedSize];
if (completion) {
completion();
}
}
];
}
- (void)didRelayoutFromOldSize:(CGSize)oldSize toNewSize:(CGSize)newSize