Commit 2616b6fe authored by techird's avatar techird

change layout vector's set position

parent 527b43e9
...@@ -42,6 +42,10 @@ kity.extendClass(MinderNode, { ...@@ -42,6 +42,10 @@ kity.extendClass(MinderNode, {
return this.getLayoutInstance().getOrderHint(this); return this.getLayoutInstance().getOrderHint(this);
}, },
getExpandPosition: function() {
return this.getLayoutInstance().getExpandPosition();
},
getLayoutInstance: function() { getLayoutInstance: function() {
var LayoutClass = KityMinder._layout[this.getLayout()]; var LayoutClass = KityMinder._layout[this.getLayout()];
var layout = new LayoutClass(); var layout = new LayoutClass();
...@@ -131,10 +135,6 @@ kity.extendClass(MinderNode, { ...@@ -131,10 +135,6 @@ kity.extendClass(MinderNode, {
this.getMinder().layout(duration); this.getMinder().layout(duration);
return this; return this;
},
getLayoutContextPoints: function() {
return this.getLayoutInstance().getLayoutContextPoints(this);
} }
}); });
...@@ -167,10 +167,17 @@ kity.extendClass(Minder, { ...@@ -167,10 +167,17 @@ kity.extendClass(Minder, {
return this.fire('layout'); return this.fire('layout');
}, },
refresh: function(duration) {
this.getRoot().preTraverse(function(node) { node.render(); });
return this.layout(duration);
},
applyLayoutResult: function(root, duration) { applyLayoutResult: function(root, duration) {
root = root || this.getRoot(); root = root || this.getRoot();
var me = this; var me = this;
if (root.getComplex() > 100) duration = 0;
function apply(node, pMatrix) { function apply(node, pMatrix) {
var matrix = node.getLayoutTransform().merge(pMatrix); var matrix = node.getLayoutTransform().merge(pMatrix);
var lastMatrix = node._lastLayoutTransform || new kity.Matrix(); var lastMatrix = node._lastLayoutTransform || new kity.Matrix();
......
...@@ -14,7 +14,7 @@ KityMinder.registerConnectProvider('default', function(node, parent, connection, ...@@ -14,7 +14,7 @@ KityMinder.registerConnectProvider('default', function(node, parent, connection,
var start, end, vector; var start, end, vector;
var abs = Math.abs; var abs = Math.abs;
var pathData = []; var pathData = [];
var side = node.getLayoutVector().x > 0 ? 'right' : 'left'; var side = box.x > pBox.x ? 'right' : 'left';
node.getMinder().getPaper().addResource(connectMarker); node.getMinder().getPaper().addResource(connectMarker);
......
...@@ -66,6 +66,12 @@ KityMinder.registerLayout('default', kity.createClass({ ...@@ -66,6 +66,12 @@ KityMinder.registerLayout('default', kity.createClass({
y = -totalTreeHeight / 2; 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++) { for (i = 0; i < children.length; i++) {
child = children[i]; child = children[i];
childTreeBox = childTreeBoxes[i]; childTreeBox = childTreeBoxes[i];
...@@ -77,15 +83,9 @@ KityMinder.registerLayout('default', kity.createClass({ ...@@ -77,15 +83,9 @@ KityMinder.registerLayout('default', kity.createClass({
if (side == 'right') { if (side == 'right') {
x = nodeContentBox.right - childContentBox.left; x = nodeContentBox.right - childContentBox.left;
x += parent.getStyle('margin-right') + child.getStyle('margin-left'); x += parent.getStyle('margin-right') + child.getStyle('margin-left');
// 设置布局矢量
child.setLayoutVector(new kity.Vector(childContentBox.right, childContentBox.cy));
} else { } else {
x = nodeContentBox.left - childContentBox.right; x = nodeContentBox.left - childContentBox.right;
x -= parent.getStyle('margin-left') + child.getStyle('margin-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