mirror of
https://github.com/TextureGroup/Texture.git
synced 2026-04-07 19:17:39 +00:00
Fix scroll node in yoga (#1435)
* fix SIMULATE_WEB_RESPONSE not imported #449
* Fix to make rangeMode update in right time
* remove uncessary assert
* Fix collection cell editing bug for iOS 9 & 10
* Revert "Fix collection cell editing bug for iOS 9 & 10"
This reverts commit 06e18a1059.
* Fix child not fit to full scroll node's bounds when flex_grow = 1.0 is used on child
This commit is contained in:
@@ -111,6 +111,21 @@
|
||||
if (ASPointsValidForLayout(selfSize.height) == NO) {
|
||||
selfSize.height = _contentCalculatedSizeFromLayout.height;
|
||||
}
|
||||
|
||||
// The side effect for layout with CGFLOAT_MAX is that the min-height/width on the child of
|
||||
// ScrollNode may not be applied correctly. Resulting in the contentSize less than the
|
||||
// scrollNode's bounds which may not be what the child want (e.g. The child want to fill
|
||||
// ScrollNode's bounds). In that case we need to give it a chance to layout with ScrollNode's
|
||||
// bound in case children want to fill the ScrollNode's bound.
|
||||
if ((ASScrollDirectionContainsVerticalDirection(_scrollableDirections) &&
|
||||
layout.size.height < selfSize.height) ||
|
||||
(ASScrollDirectionContainsHorizontalDirection(_scrollableDirections) &&
|
||||
layout.size.width < selfSize.width)) {
|
||||
layout = [super calculateLayoutThatFits:constrainedSize
|
||||
restrictedToSize:size
|
||||
relativeToParentSize:parentSize];
|
||||
}
|
||||
|
||||
// Don't provide a position, as that should be set by the parent.
|
||||
layout = [ASLayout layoutWithLayoutElement:self
|
||||
size:selfSize
|
||||
|
||||
@@ -104,6 +104,40 @@
|
||||
ASXCTAssertEqualSizes(self.scrollNode.view.contentSize, subnodeSize);
|
||||
}
|
||||
|
||||
- (void)testAutomaticallyManagesContentSizeWithSizeRangeSmallerThanParentSizeFillContainer
|
||||
{
|
||||
CGSize subnodeSize = CGSizeMake(100, 200);
|
||||
CGSize parentSize = CGSizeMake(100, 500);
|
||||
ASSizeRange sizeRange = ASSizeRangeMake(CGSizeMake(100, 200), CGSizeMake(100, 200));
|
||||
|
||||
self.subnode.style.flexGrow = 1.0;
|
||||
self.subnode.style.minHeight = ASDimensionMake(ASDimensionUnitPoints, 50.0);
|
||||
self.subnode.style.width = ASDimensionMake(ASDimensionUnitPoints, 100.0);
|
||||
[self.scrollNode layoutThatFits:sizeRange parentSize:parentSize];
|
||||
[self.scrollNode layout];
|
||||
|
||||
ASXCTAssertEqualSizes(self.scrollNode.calculatedSize, sizeRange.max);
|
||||
ASXCTAssertEqualSizes(self.scrollNode.view.contentSize, subnodeSize);
|
||||
}
|
||||
|
||||
// It's expected that the contentSize is 100x100 when ScrollNode's bounds is 100x200, which currently
|
||||
// not the case for LayoutSepc but work in Yoga.
|
||||
- (void)disable_testAutomaticallyManagesContentSizeWithSizeRangeSmallerThanParentSizeKeepChildSize
|
||||
{
|
||||
CGSize subnodeSize = CGSizeMake(100, 100);
|
||||
CGSize parentSize = CGSizeMake(100, 200);
|
||||
ASSizeRange sizeRange = ASSizeRangeMake(CGSizeMake(100, 200), CGSizeMake(100, 200));
|
||||
|
||||
self.subnode.style.width = ASDimensionMake(ASDimensionUnitPoints, 100.0);
|
||||
self.subnode.style.height = ASDimensionMake(ASDimensionUnitPoints, 100.0);
|
||||
|
||||
[self.scrollNode layoutThatFits:sizeRange parentSize:parentSize];
|
||||
[self.scrollNode layout];
|
||||
|
||||
ASXCTAssertEqualSizes(self.scrollNode.calculatedSize, sizeRange.max);
|
||||
ASXCTAssertEqualSizes(self.scrollNode.view.contentSize, subnodeSize);
|
||||
}
|
||||
|
||||
- (void)testAutomaticallyManagesContentSizeWithSizeRangeBiggerThanParentSize
|
||||
{
|
||||
CGSize subnodeSize = CGSizeMake(100, 200);
|
||||
|
||||
Reference in New Issue
Block a user