From 4b2aa1fc59237ed4b7adf0741799d51799b93d14 Mon Sep 17 00:00:00 2001 From: Luke Parham Date: Thu, 28 Apr 2016 03:27:53 -0500 Subject: [PATCH] added comments to header and cleaned up interface state did change --- AsyncDisplayKit/ASDisplayNode+Subclasses.h | 23 +++++++++++++++++ AsyncDisplayKit/ASDisplayNode.mm | 30 ++++++---------------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/AsyncDisplayKit/ASDisplayNode+Subclasses.h b/AsyncDisplayKit/ASDisplayNode+Subclasses.h index 7422598e8a..96fe28bf5f 100644 --- a/AsyncDisplayKit/ASDisplayNode+Subclasses.h +++ b/AsyncDisplayKit/ASDisplayNode+Subclasses.h @@ -242,9 +242,32 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)visibilityDidChange:(BOOL)isVisible ASDISPLAYNODE_REQUIRES_SUPER; +/** + * @abstract Called whenever the the node enters the display range. + * + * @discussion Subclasses may use this to monitor when they enter the display range. + */ - (void)didEnterDisplayRange ASDISPLAYNODE_REQUIRES_SUPER; + +/** + * @abstract Called whenever the the node exits the display range. + * + * @discussion Subclasses may use this to monitor when they exit the display range. + */ - (void)didExitDisplayRange ASDISPLAYNODE_REQUIRES_SUPER; + +/** + * @abstract Called whenever the the node enters the fetch data range. + * + * @discussion Subclasses may use this to monitor when they enter the fetch data range. + */ - (void)didEnterFetchDataRange ASDISPLAYNODE_REQUIRES_SUPER; + +/** + * @abstract Called whenever the the node exits the fetch data range. + * + * @discussion Subclasses may use this to monitor when they exit the fetch data range. + */ - (void)didExitFetchDataRange ASDISPLAYNODE_REQUIRES_SUPER; /** diff --git a/AsyncDisplayKit/ASDisplayNode.mm b/AsyncDisplayKit/ASDisplayNode.mm index dc0bcf24c2..d40a466573 100644 --- a/AsyncDisplayKit/ASDisplayNode.mm +++ b/AsyncDisplayKit/ASDisplayNode.mm @@ -2242,10 +2242,12 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock) if (nowFetchData != wasFetchData) { if (nowFetchData) { [self fetchData]; + [self didEnterFetchDataRange]; } else { if ([self supportsRangeManagedInterfaceState]) { [self clearFetchedData]; } + [self didExitFetchDataRange]; } } @@ -2289,6 +2291,12 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock) } } } + + if (nowDisplay) { + [self didEnterDisplayRange]; + } else { + [self didExitDisplayRange]; + } } // Became visible or invisible. When range-managed, this represents literal visibility - at least one pixel @@ -2299,29 +2307,7 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock) if (nowVisible != wasVisible) { [self visibilityDidChange:nowVisible]; } - - BOOL nowInDisplay = ASInterfaceStateIncludesDisplay(newState); - BOOL wasInDisplay = ASInterfaceStateIncludesDisplay(oldState); - - if (nowInDisplay != wasInDisplay) { - if (nowInDisplay) { - [self didEnterDisplayRange]; - } else { - [self didExitDisplayRange]; - } - } - - BOOL nowInFetchData = ASInterfaceStateIncludesFetchData(newState); - BOOL wasInFetchData = ASInterfaceStateIncludesFetchData(oldState); - if (nowInFetchData != wasInFetchData) { - if (nowInFetchData) { - [self didEnterFetchDataRange]; - } else { - [self didExitFetchDataRange]; - } - } - [self interfaceStateDidChange:newState fromState:oldState]; }