Commit b3e4a489 authored by 张博's avatar 张博

fixed bug: 存在折叠节点的情况下,拖拽节点会成为折叠节点的子节点

parent b0543183
......@@ -2,7 +2,7 @@
"name": "kityminder-core",
"title": "Kity Minder Core",
"description": "Powerful online mind graphic visualization and editor (command based)",
"version": "1.4.16",
"version": "1.4.17",
"main": [
"dist/kityminder.core.min.js",
"dist/kityminder.core.css"
......
/*!
* ====================================================
* kityminder - v1.4.1 - 2015-09-06
* kityminder - v1.4.1 - 2015-09-08
* https://github.com/fex-team/kityminder-core
* GitHub: https://github.com/fex-team/kityminder-core.git
* Copyright (c) 2015 Baidu FEX; Licensed MIT
......@@ -1801,7 +1801,7 @@ _p[18] = {
this.fire("finishInitHook");
}
});
Minder.version = "1.4.16";
Minder.version = "1.4.17";
Minder.registerInitHook = function(hook) {
_initHooks.push(hook);
};
......@@ -4598,6 +4598,14 @@ _p[43] = {
this._text.setPosition(this._startPosition.x, this._startPosition.y + 5);
this._minder.getRenderContainer().addShape(this);
},
/**
* 通过 judge 函数判断 targetBox 和 sourceBox 的位置交叉关系
* @param targets -- 目标节点
* @param targetBoxMapper -- 目标节点与对应 Box 的映射关系
* @param judge -- 判断函数
* @returns {*}
* @private
*/
_boxTest: function(targets, targetBoxMapper, judge) {
var sourceBoxes = this._dragSources.map(function(source) {
return source.getLayoutBox();
......@@ -4627,8 +4635,17 @@ _p[43] = {
return box.width * box.height;
}
if (!intersectBox) return false;
// 面积判断
/*
* Added by zhangbobell, 2015.9.8
*
* 增加了下面一行判断,修复了循环比较中 targetBox 为折叠节点时,intersetBox 面积为 0,
* 而 targetBox 的 width 和 height 均为 0
* 此时造成了满足以下的第二个条件而返回 true
* */
if (!!area(intersectBox)) return false;
// 面积判断,交叉面积大于其中的一半
if (area(intersectBox) > .5 * Math.min(area(sourceBox), area(targetBox))) return true;
// 有一个边完全重合的情况,也认为两个是交叉的
if (intersectBox.width + 1 >= Math.min(sourceBox.width, targetBox.width)) return true;
if (intersectBox.height + 1 >= Math.min(sourceBox.height, targetBox.height)) return true;
return false;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -30,7 +30,7 @@ define(function(require, exports, module) {
}
});
Minder.version = '1.4.16';
Minder.version = '1.4.17';
Minder.registerInitHook = function(hook) {
_initHooks.push(hook);
......
......@@ -281,6 +281,14 @@ define(function(require, exports, module) {
this._minder.getRenderContainer().addShape(this);
},
/**
* 通过 judge 函数判断 targetBox 和 sourceBox 的位置交叉关系
* @param targets -- 目标节点
* @param targetBoxMapper -- 目标节点与对应 Box 的映射关系
* @param judge -- 判断函数
* @returns {*}
* @private
*/
_boxTest: function(targets, targetBoxMapper, judge) {
var sourceBoxes = this._dragSources.map(function(source) {
return source.getLayoutBox();
......@@ -318,8 +326,17 @@ define(function(require, exports, module) {
return box.width * box.height;
}
if (!intersectBox) return false;
// 面积判断
/*
* Added by zhangbobell, 2015.9.8
*
* 增加了下面一行判断,修复了循环比较中 targetBox 为折叠节点时,intersetBox 面积为 0,
* 而 targetBox 的 width 和 height 均为 0
* 此时造成了满足以下的第二个条件而返回 true
* */
if (!!area(intersectBox)) return false;
// 面积判断,交叉面积大于其中的一半
if (area(intersectBox) > 0.5 * Math.min(area(sourceBox), area(targetBox))) return true;
// 有一个边完全重合的情况,也认为两个是交叉的
if (intersectBox.width + 1 >= Math.min(sourceBox.width, targetBox.width)) return true;
if (intersectBox.height + 1 >= Math.min(sourceBox.height, targetBox.height)) return true;
return false;
......
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