Add expectedSize to ASNetworkImageNode

ASNetworkImageNode defers to ASImageNode to return its calculatedSize. ASImageNode returns the size of its image. There is a good chance that ASNetworkImageNode hasn't downloaded its image yet when calculatedSize is called, so it returns a size of CGSizeZero.

On top of that, it is possible that the size of the image is not actually the size that we wish to display in our node.

I've added an "expectedImageSize" property that can be used to determine the calculatedSize of an ASNetworkImageNode.
This commit is contained in:
ricky cancro
2015-07-30 16:50:11 -07:00
committed by rcancro
parent 8da9ddd884
commit b58e8344c0
4 changed files with 27 additions and 6 deletions

View File

@@ -111,7 +111,9 @@
- (CGSize)calculateSizeThatFits:(CGSize)constrainedSize
{
ASDN::MutexLocker l(_imageLock);
if (_image)
if (CGSizeEqualToSize(self.preferredFrameSize, CGSizeZero) == NO)
return CGSizeMake(MIN(constrainedSize.width, self.preferredFrameSize.width), MIN(constrainedSize.height, self.preferredFrameSize.height));
else if (_image)
return _image.size;
else
return CGSizeZero;