Commit 2616b6fe authored by techird's avatar techird

change layout vector's set position

parent 527b43e9
......@@ -42,6 +42,10 @@ kity.extendClass(MinderNode, {
return this.getLayoutInstance().getOrderHint(this);
},
getExpandPosition: function() {
return this.getLayoutInstance().getExpandPosition();
},
getLayoutInstance: function() {
var LayoutClass = KityMinder._layout[this.getLayout()];
var layout = new LayoutClass();
......@@ -131,10 +135,6 @@ kity.extendClass(MinderNode, {
this.getMinder().layout(duration);
return this;
},
getLayoutContextPoints: function() {
return this.getLayoutInstance().getLayoutContextPoints(this);
}
});
......@@ -167,10 +167,17 @@ kity.extendClass(Minder, {
return this.fire('layout');
},
refresh: function(duration) {
this.getRoot().preTraverse(function(node) { node.render(); });
return this.layout(duration);
},
applyLayoutResult: function(root, duration) {
root = root || this.getRoot();
var me = this;
if (root.getComplex() > 100) duration = 0;
function apply(node, pMatrix) {
var matrix = node.getLayoutTransform().merge(pMatrix);
var lastMatrix = node._lastLayoutTransform || new kity.Matrix();
......
......@@ -14,7 +14,7 @@ KityMinder.registerConnectProvider('default', function(node, parent, connection,
var start, end, vector;
var abs = Math.abs;
var pathData = [];
var side = node.getLayoutVector().x > 0 ? 'right' : 'left';
var side = box.x > pBox.x ? 'right' : 'left';
node.getMinder().getPaper().addResource(connectMarker);
......
......@@ -66,6 +66,12 @@ KityMinder.registerLayout('default', kity.createClass({
y = -totalTreeHeight / 2;
if (side != 'left') {
parent.setLayoutVector(new kity.Vector(nodeContentBox.right, nodeContentBox.cy));
} else {
parent.setLayoutVector(new kity.Vector(nodeContentBox.left, nodeContentBox.cy));
}
for (i = 0; i < children.length; i++) {
child = children[i];
childTreeBox = childTreeBoxes[i];
......@@ -77,15 +83,9 @@ KityMinder.registerLayout('default', kity.createClass({
if (side == 'right') {
x = nodeContentBox.right - childContentBox.left;
x += parent.getStyle('margin-right') + child.getStyle('margin-left');
// 设置布局矢量
child.setLayoutVector(new kity.Vector(childContentBox.right, childContentBox.cy));
} else {
x = nodeContentBox.left - childContentBox.right;
x -= parent.getStyle('margin-left') + child.getStyle('margin-right');
// 设置布局矢量
child.setLayoutVector(new kity.Vector(childContentBox.left, childContentBox.cy));
}
// 竖直方向上的布局
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment