From d65d15cc4116efa9f31faf7cc4c1ac55b504b772 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Mon, 14 Apr 2014 12:00:16 -0700 Subject: [PATCH] layout flex-end should take into account margin --- spec/LayoutSpec.js | 14 ++++++++++++++ src/Layout.js | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/spec/LayoutSpec.js b/spec/LayoutSpec.js index c7889973..d81d43a5 100755 --- a/spec/LayoutSpec.js +++ b/spec/LayoutSpec.js @@ -493,6 +493,20 @@ describe('Layout', function() { }); }); + it('should layout flex-end taking into account margin', function() { + testLayout({ + style: {height: 100, justifyContent: 'flex-end'}, + children: [ + {style: {marginTop: 10}} + ] + }, { + width: 0, height: 100, top: 0, left: 0, + children: [ + {width: 0, height: 0, top: 100, left: 0} + ] + }); + }); + it('should layout randomly', function() { function RNG(seed) { this.state = seed; diff --git a/src/Layout.js b/src/Layout.js index 957f18fe..e96db670 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -111,7 +111,9 @@ function computeLayout(node) { children.forEach(function(child) { if (!child.style.flex) { layoutNode(child); - mainContentDim += child.layout[dim[mainAxis]]; + mainContentDim += child.layout[dim[mainAxis]] + + getMargin(leading[mainAxis], child) + + getMargin(trailing[mainAxis], child); } else { flexibleChildrenCount++; }