Commit c3e1e305 authored by techird's avatar techird

fix drag issue

parent dffc0887
......@@ -7,26 +7,26 @@
<meta name="description" content="百度脑图,便捷的脑图编辑工具。让您在线上直接创建、保存并分享你的思路。">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<script src="lib/jquery-2.1.0.min.js?_=1406187190589" charset="utf-8"></script>
<script src="lib/ZeroClipboard.min.js?_=1406187190589" charset="utf-8"></script>
<script src="lib/jquery-2.1.0.min.js?_=1406193886421" charset="utf-8"></script>
<script src="lib/ZeroClipboard.min.js?_=1406193886421" charset="utf-8"></script>
<script type="text/javascript">
ZeroClipboard.setDefaults( { moviePath: 'lib/ZeroClipboard.swf' } );
</script>
<script src="lib/kity.min.js?_=1406187190589" charset="utf-8"></script>
<script src="kityminder.all.min.js?_=1406187190589" charset="utf-8"></script>
<script src="kityminder.config.js?_=1406187190589" charset="utf-8"></script>
<script src="lang/zh-cn/zh-cn.js?_=1406187190589" charset="utf-8"></script>
<script src="lib/kity.min.js?_=1406193886421" charset="utf-8"></script>
<script src="kityminder.all.min.js?_=1406193886421" charset="utf-8"></script>
<script src="kityminder.config.js?_=1406193886421" charset="utf-8"></script>
<script src="lang/zh-cn/zh-cn.js?_=1406193886421" charset="utf-8"></script>
<script src="lib/zip.js?_=1406187190589" charset="utf-8"></script>
<script src="lib/zip.js?_=1406193886421" charset="utf-8"></script>
<script>
zip.inflateJSPath = 'lib/inflate.js';
</script>
<script src="lib/jquery.xml2json.js?_=1406187190589" charset="utf-8"></script>
<script src="lib/baidu-frontia-js-full-1.0.0.js?_=1406187190589" charset="utf-8"></script>
<script src="social/draftmanager.js?_=1406187190589" charset="utf-8"></script>
<script src="social/social.js?_=1406187190589" charset="utf-8"></script>
<script src="lib/jquery.xml2json.js?_=1406193886421" charset="utf-8"></script>
<script src="lib/baidu-frontia-js-full-1.0.0.js?_=1406193886421" charset="utf-8"></script>
<script src="social/draftmanager.js?_=1406193886421" charset="utf-8"></script>
<script src="social/social.js?_=1406193886421" charset="utf-8"></script>
<link href="social/social.css" rel="stylesheet">
<link href="themes/default/css/import.css" type="text/css" rel="stylesheet" />
......
......@@ -988,19 +988,28 @@ var Minder = KityMinder.Minder = kity.createClass('KityMinder', {
this._status = 'normal';
this._rollbackStatus = 'normal';
},
setStatus: function(status) {
if (status != this._status) {
this.fire('statuschange',{
lastStatus:this._status,
currentStatus:status
});
// console.log(window.event.type, this._status, '->', status);
// console.trace();
this._rollbackStatus = this._status;
this._status = status;
}
return this;
},
setStatus: (function() {
var sf = ~window.location.href.indexOf('status');
var tf = ~window.location.href.indexOf('trace');
return function(status) {
if (status != this._status) {
this._rollbackStatus = this._status;
this._status = status;
this.fire('statuschange', {
lastStatus: this._rollbackStatus,
currentStatus: this._status
});
if (sf) {
console.log(window.event.type, this._rollbackStatus, '->', this._status);
if (tf) {
console.trace();
}
}
}
return this;
};
})(),
rollbackStatus: function() {
this.setStatus(this._rollbackStatus);
},
......@@ -4219,7 +4228,7 @@ KityMinder.registerModule('Expand', function() {
if (this.getStatus() == 'textedit') return;
if (e.originEvent.keyCode == keymap['/']) {
var node = this.getSelectedNode();
if (!node) return;
if (!node || node == this.getRoot()) return;
var expanded = node.isExpanded();
this.getSelectedNodes().forEach(function(node) {
if (expanded) node.collapse();
......@@ -5714,6 +5723,9 @@ var TreeDragger = kity.createClass('TreeDragger', {
if (!this._dragMode) {
return;
}
this._fadeDragSources(1);
if (this._dropSucceedTarget) {
this._dragSources.forEach(function(source) {
......@@ -5763,6 +5775,7 @@ var TreeDragger = kity.createClass('TreeDragger', {
this._calcDropTargets();
this._calcOrderHints();
this._dragMode = true;
this._minder.setStatus('dragtree');
return true;
},
......@@ -5786,14 +5799,12 @@ var TreeDragger = kity.createClass('TreeDragger', {
this._dragSources.forEach(function(source) {
source.getRenderContainer().fxOpacity(opacity, 200);
source.traverse(function(node) {
if (opacity < 1) minder.detachNode(node);
else minder.attachNode(node);
if (opacity < 1) {
minder.detachNode(node);
} else {
minder.attachNode(node);
}
}, true);
if (opacity < 1) {
minder.removeConnect(source);
} else {
minder.createConnect(source);
}
});
},
......@@ -5851,12 +5862,12 @@ var TreeDragger = kity.createClass('TreeDragger', {
},
_leaveDragMode: function() {
this._fadeDragSources(1);
this._dragMode = false;
this._dropSucceedTarget = null;
this._orderSucceedHint = null;
this._renderDropHint(null);
this._renderOrderHint(null);
this._minder.rollbackStatus();
},
_drawForDragMode: function() {
......@@ -5938,6 +5949,9 @@ KityMinder.registerModule('DragTree', function() {
return {
init: function() {
dragger = new TreeDragger(this);
window.addEventListener('mouseup', function() {
dragger.dragEnd();
});
},
events: {
'normal.mousedown inputready.mousedown': function(e) {
......@@ -5947,12 +5961,13 @@ KityMinder.registerModule('DragTree', function() {
dragger.dragStart(e.getPosition(this.getRenderContainer()));
}
},
'normal.mousemove': function(e) {
'normal.mousemove dragtree.mousemove': function(e) {
dragger.dragMove(e.getPosition(this.getRenderContainer()));
},
'normal.mouseup': function(e) {
dragger.dragEnd(e.getPosition(this.getRenderContainer()));
e.stopPropagation();
'normal.mouseup dragtree.beforemouseup': function(e) {
dragger.dragEnd();
//e.stopPropagation();
e.preventDefault();
this.fire('contentchange');
},
'statuschange': function(e) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -175,19 +175,28 @@ var Minder = KityMinder.Minder = kity.createClass('KityMinder', {
this._status = 'normal';
this._rollbackStatus = 'normal';
},
setStatus: function(status) {
if (status != this._status) {
this.fire('statuschange',{
lastStatus:this._status,
currentStatus:status
});
// console.log(window.event.type, this._status, '->', status);
// console.trace();
this._rollbackStatus = this._status;
this._status = status;
}
return this;
},
setStatus: (function() {
var sf = ~window.location.href.indexOf('status');
var tf = ~window.location.href.indexOf('trace');
return function(status) {
if (status != this._status) {
this._rollbackStatus = this._status;
this._status = status;
this.fire('statuschange', {
lastStatus: this._rollbackStatus,
currentStatus: this._status
});
if (sf) {
console.log(window.event.type, this._rollbackStatus, '->', this._status);
if (tf) {
console.trace();
}
}
}
return this;
};
})(),
rollbackStatus: function() {
this.setStatus(this._rollbackStatus);
},
......
......@@ -175,6 +175,7 @@ var TreeDragger = kity.createClass('TreeDragger', {
this._calcDropTargets();
this._calcOrderHints();
this._dragMode = true;
this._minder.setStatus('dragtree');
return true;
},
......@@ -204,11 +205,6 @@ var TreeDragger = kity.createClass('TreeDragger', {
minder.attachNode(node);
}
}, true);
if (opacity < 1) {
minder.removeConnect(source);
} else {
minder.createConnect(source);
}
});
},
......@@ -271,6 +267,7 @@ var TreeDragger = kity.createClass('TreeDragger', {
this._orderSucceedHint = null;
this._renderDropHint(null);
this._renderOrderHint(null);
this._minder.rollbackStatus();
},
_drawForDragMode: function() {
......@@ -352,6 +349,9 @@ KityMinder.registerModule('DragTree', function() {
return {
init: function() {
dragger = new TreeDragger(this);
window.addEventListener('mouseup', function() {
dragger.dragEnd();
});
},
events: {
'normal.mousedown inputready.mousedown': function(e) {
......@@ -361,12 +361,13 @@ KityMinder.registerModule('DragTree', function() {
dragger.dragStart(e.getPosition(this.getRenderContainer()));
}
},
'normal.mousemove': function(e) {
'normal.mousemove dragtree.mousemove': function(e) {
dragger.dragMove(e.getPosition(this.getRenderContainer()));
},
'normal.mouseup': function(e) {
dragger.dragEnd(e.getPosition(this.getRenderContainer()));
e.stopPropagation();
'normal.mouseup dragtree.beforemouseup': function(e) {
dragger.dragEnd();
//e.stopPropagation();
e.preventDefault();
this.fire('contentchange');
},
'statuschange': function(e) {
......
......@@ -233,7 +233,7 @@ KityMinder.registerModule('Expand', function() {
if (this.getStatus() == 'textedit') return;
if (e.originEvent.keyCode == keymap['/']) {
var node = this.getSelectedNode();
if (!node) return;
if (!node || node == this.getRoot()) return;
var expanded = node.isExpanded();
this.getSelectedNodes().forEach(function(node) {
if (expanded) node.collapse();
......
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