diff --git a/AsyncDisplayKit/Private/ASStackPositionedLayout.mm b/AsyncDisplayKit/Private/ASStackPositionedLayout.mm index c38cf797bf..1fdef8eb0b 100644 --- a/AsyncDisplayKit/Private/ASStackPositionedLayout.mm +++ b/AsyncDisplayKit/Private/ASStackPositionedLayout.mm @@ -118,12 +118,13 @@ ASStackPositionedLayout ASStackPositionedLayout::compute(const ASStackUnposition return stackedLayout(style, violation, unpositionedLayout, constrainedSize); } case ASStackLayoutJustifyContentSpaceBetween: { + // Spacing between the items, no spaces at the edges, evenly distributed const auto numOfSpacings = numOfItems - 1; - return stackedLayout(style, 0, std::floor(violation / numOfSpacings), std::fmod(violation, numOfSpacings), unpositionedLayout, constrainedSize); + return stackedLayout(style, 0, violation / numOfSpacings, 0, unpositionedLayout, constrainedSize); } case ASStackLayoutJustifyContentSpaceAround: { // Spacing between items are twice the spacing on the edges - CGFloat spacingUnit = std::floor(violation / (numOfItems * 2)); + CGFloat spacingUnit = violation / (numOfItems * 2); return stackedLayout(style, spacingUnit, spacingUnit * 2, 0, unpositionedLayout, constrainedSize); } } diff --git a/AsyncDisplayKitTests/ASStackLayoutSpecSnapshotTests.mm b/AsyncDisplayKitTests/ASStackLayoutSpecSnapshotTests.mm index a23edd0ff9..e82fbe7f12 100644 --- a/AsyncDisplayKitTests/ASStackLayoutSpecSnapshotTests.mm +++ b/AsyncDisplayKitTests/ASStackLayoutSpecSnapshotTests.mm @@ -340,14 +340,14 @@ static void setCGSizeToNode(CGSize size, ASDisplayNode *node) - (void)testJustifiedSpaceBetweenWithRemainingSpace { - // width 301px; height 0-300px; 1px remaining + // width 301px; height 0-300px; static ASSizeRange kSize = {{301, 0}, {301, 300}}; [self testStackLayoutSpecWithJustify:ASStackLayoutJustifyContentSpaceBetween flexFactor:0 sizeRange:kSize identifier:nil]; } - (void)testJustifiedSpaceAroundWithRemainingSpace { - // width 305px; height 0-300px; 5px remaining + // width 305px; height 0-300px; static ASSizeRange kSize = {{305, 0}, {305, 300}}; [self testStackLayoutSpecWithJustify:ASStackLayoutJustifyContentSpaceAround flexFactor:0 sizeRange:kSize identifier:nil]; } diff --git a/AsyncDisplayKitTests/ReferenceImages_64/ASStackLayoutSpecSnapshotTests/testJustifiedSpaceAroundWithRemainingSpace@2x.png b/AsyncDisplayKitTests/ReferenceImages_64/ASStackLayoutSpecSnapshotTests/testJustifiedSpaceAroundWithRemainingSpace@2x.png index 088b49a293..6de6f28efc 100644 Binary files a/AsyncDisplayKitTests/ReferenceImages_64/ASStackLayoutSpecSnapshotTests/testJustifiedSpaceAroundWithRemainingSpace@2x.png and b/AsyncDisplayKitTests/ReferenceImages_64/ASStackLayoutSpecSnapshotTests/testJustifiedSpaceAroundWithRemainingSpace@2x.png differ diff --git a/AsyncDisplayKitTests/ReferenceImages_64/ASStackLayoutSpecSnapshotTests/testJustifiedSpaceBetweenWithRemainingSpace@2x.png b/AsyncDisplayKitTests/ReferenceImages_64/ASStackLayoutSpecSnapshotTests/testJustifiedSpaceBetweenWithRemainingSpace@2x.png index 4f85986130..8ee77c8de5 100644 Binary files a/AsyncDisplayKitTests/ReferenceImages_64/ASStackLayoutSpecSnapshotTests/testJustifiedSpaceBetweenWithRemainingSpace@2x.png and b/AsyncDisplayKitTests/ReferenceImages_64/ASStackLayoutSpecSnapshotTests/testJustifiedSpaceBetweenWithRemainingSpace@2x.png differ