nested children
This commit is contained in:
@@ -810,7 +810,7 @@ getJasmineRequireObj().Any = function() {
|
|||||||
if (this.expectedObject == Object) {
|
if (this.expectedObject == Object) {
|
||||||
return typeof other == 'object';
|
return typeof other == 'object';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.expectedObject == Boolean) {
|
if (this.expectedObject == Boolean) {
|
||||||
return typeof other == 'boolean';
|
return typeof other == 'boolean';
|
||||||
}
|
}
|
||||||
@@ -1767,10 +1767,10 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
|||||||
expected = args.slice(3),
|
expected = args.slice(3),
|
||||||
englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
|
englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
|
||||||
|
|
||||||
var message = "Expected " +
|
var message = "Expected \n " +
|
||||||
j$.pp(actual) +
|
j$.pp(actual) +
|
||||||
(isNot ? " not " : " ") +
|
(isNot ? " not " : " \n") +
|
||||||
englishyPredicate;
|
englishyPredicate + "\n";
|
||||||
|
|
||||||
if (expected.length > 0) {
|
if (expected.length > 0) {
|
||||||
for (var i = 0; i < expected.length; i++) {
|
for (var i = 0; i < expected.length; i++) {
|
||||||
|
@@ -88,7 +88,7 @@ describe('Layout', function() {
|
|||||||
testLayout({
|
testLayout({
|
||||||
style: {width: 100, height: 200}
|
style: {width: 100, height: 200}
|
||||||
}, {
|
}, {
|
||||||
width: 100, height: 200, left: 0, top: 0
|
width: 100, height: 200, top: 0, left: 0
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ describe('Layout', function() {
|
|||||||
{style: {width: 125, height: 125}}
|
{style: {width: 125, height: 125}}
|
||||||
]
|
]
|
||||||
}, {
|
}, {
|
||||||
width: 1000, height: 1000, left: 0, top: 0,
|
width: 1000, height: 1000, top: 0, left: 0,
|
||||||
children: [
|
children: [
|
||||||
{width: 500, height: 500, top: 0, left: 0},
|
{width: 500, height: 500, top: 0, left: 0},
|
||||||
{width: 250, height: 250, top: 500, left: 0},
|
{width: 250, height: 250, top: 500, left: 0},
|
||||||
@@ -109,5 +109,31 @@ describe('Layout', function() {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should layout node with nested children', function() {
|
||||||
|
testLayout({
|
||||||
|
style: {width: 1000, height: 1000},
|
||||||
|
children: [{
|
||||||
|
style: {width: 500, height: 500}
|
||||||
|
}, {
|
||||||
|
style: {width: 500, height: 500},
|
||||||
|
children: [
|
||||||
|
{style: {width: 250, height: 250}},
|
||||||
|
{style: {width: 250, height: 250}}
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
}, {
|
||||||
|
width: 1000, height: 1000, top: 0, left: 0,
|
||||||
|
children: [{
|
||||||
|
width: 500, height: 500, top: 0, left: 0
|
||||||
|
}, {
|
||||||
|
width: 500, height: 500, top: 500, left: 0,
|
||||||
|
children: [
|
||||||
|
{width: 250, height: 250, top: 0, left: 0},
|
||||||
|
{width: 250, height: 250, top: 250, left: 0},
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -1,28 +1,30 @@
|
|||||||
|
|
||||||
function computeLayout(node) {
|
function computeLayout(node) {
|
||||||
var top = 0;
|
|
||||||
var children = [];
|
function layoutNode(node, parent) {
|
||||||
(node.children || []).forEach(function(child) {
|
var top = 0;
|
||||||
console.log(child);
|
var children = [];
|
||||||
children.push({
|
(node.children || []).forEach(function(child) {
|
||||||
top: top,
|
children.push(layoutNode(child, {
|
||||||
left: 0,
|
top: top,
|
||||||
width: child.style.width,
|
left: 0
|
||||||
height: child.style.height
|
}));
|
||||||
|
top += child.style.height;
|
||||||
});
|
});
|
||||||
top += child.style.height;
|
|
||||||
});
|
|
||||||
|
|
||||||
var result = {
|
var result = {
|
||||||
top: 0,
|
width: node.style.width,
|
||||||
left: 0,
|
height: node.style.height,
|
||||||
width: node.style.width,
|
top: parent.top + 0,
|
||||||
height: node.style.height
|
left: parent.left + 0
|
||||||
};
|
};
|
||||||
|
|
||||||
if (children.length > 0) {
|
if (children.length > 0) {
|
||||||
result.children = children;
|
result.children = children;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
|
return layoutNode(node, {top: 0, left: 0});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user