Commit bf1ae615 authored by campaign's avatar campaign

Merge branch 'dev' into gh-pages

parents de0293e2 e02893e6
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
"utils", "utils",
"$", "$",
"KM", "KM",
"keymap" "keymap",
"baidu"
] ]
} }
\ No newline at end of file
...@@ -9,7 +9,8 @@ KM.registerToolbarUI( 'saveto', function ( name ) { ...@@ -9,7 +9,8 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
items: [], items: [],
itemStyles: [], itemStyles: [],
value: [], value: [],
autowidthitem: [] autowidthitem: [],
enabledRecord:false
}, },
$combox = null, $combox = null,
comboboxWidget = null; comboboxWidget = null;
......
...@@ -79,6 +79,12 @@ var DragBox = kity.createClass( "DragBox", { ...@@ -79,6 +79,12 @@ var DragBox = kity.createClass( "DragBox", {
ancestors = [], ancestors = [],
judge; judge;
// 根节点不参与计算
var rootIndex = nodes.indexOf( this._minder.getRoot() );
if ( ~rootIndex ) {
nodes.splice( rootIndex, 1 );
}
// 判断 nodes 列表中是否存在 judge 的祖先 // 判断 nodes 列表中是否存在 judge 的祖先
function hasAncestor( nodes, judge ) { function hasAncestor( nodes, judge ) {
for ( var i = nodes.length - 1; i >= 0; --i ) { for ( var i = nodes.length - 1; i >= 0; --i ) {
...@@ -137,10 +143,15 @@ var DragBox = kity.createClass( "DragBox", { ...@@ -137,10 +143,15 @@ var DragBox = kity.createClass( "DragBox", {
// 4. 标记已启动 // 4. 标记已启动
_enterDragMode: function () { _enterDragMode: function () {
this._calcDragSources(); this._calcDragSources();
if ( !this._dragSources.length ) {
this._startPosition = null;
return false;
}
this._calcDropTargets(); this._calcDropTargets();
this._drawForDragMode(); this._drawForDragMode();
this._shrink(); this._shrink();
this._dragMode = true; this._dragMode = true;
return true;
}, },
_leaveDragMode: function () { _leaveDragMode: function () {
this.remove(); this.remove();
...@@ -227,16 +238,21 @@ var DragBox = kity.createClass( "DragBox", { ...@@ -227,16 +238,21 @@ var DragBox = kity.createClass( "DragBox", {
}, },
dragMove: function ( position ) { dragMove: function ( position ) {
// 启动拖放模式需要最小的移动距离
var DRAG_MOVE_THRESHOLD = 10;
if ( !this._startPosition ) return; if ( !this._startPosition ) return;
this._dragPosition = position; this._dragPosition = position;
if ( !this._dragMode ) { if ( !this._dragMode ) {
// 判断拖放模式是否该启动 // 判断拖放模式是否该启动
if ( GM.getDistance( this._dragPosition, this._startPosition ) < 10 ) { if ( GM.getDistance( this._dragPosition, this._startPosition ) < DRAG_MOVE_THRESHOLD ) {
return;
}
if ( !this._enterDragMode() ) {
return; return;
} }
this._enterDragMode();
} }
var movement = kity.Vector.fromPoints( this._startPosition, this._dragPosition ); var movement = kity.Vector.fromPoints( this._startPosition, this._dragPosition );
...@@ -269,7 +285,8 @@ KityMinder.registerModule( "DragTree", function () { ...@@ -269,7 +285,8 @@ KityMinder.registerModule( "DragTree", function () {
}, },
events: { events: {
mousedown: function ( e ) { mousedown: function ( e ) {
if ( e.getTargetNode() ) { // 单选中根节点也不触发拖拽
if ( e.getTargetNode() && e.getTargetNode() != this.getRoot() ) {
this._dragBox.dragStart( e.getPosition() ); this._dragBox.dragStart( e.getPosition() );
} }
}, },
......
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