Commit 890bdcdc authored by techird's avatar techird

添加右键拖动的功能

parent 4d023087
......@@ -27,7 +27,11 @@ KM.registerUI( 'contextmenu', function () {
}
});
me.$container.append($menu);
me.on('contextmenu',function(e){
me.on('contextmenu', function (e) {
e.preventDefault();
if (me.getStatus() == 'hand') return;
var node = e.getTargetNode();
if(node){
this.removeAllSelectedNodes();
......@@ -59,7 +63,6 @@ KM.registerUI( 'contextmenu', function () {
data:data
}).position(e.getPosition()).show();
}
e.preventDefault()
});
me.on('click',function(){
......@@ -67,7 +70,7 @@ KM.registerUI( 'contextmenu', function () {
});
me.on('beforemousedown',function(e){
if(e.isRightMB()){
e.stopPropagationImmediately();
//e.stopPropagationImmediately();
}
})
} );
......
......@@ -24,20 +24,21 @@ var ViewDragger = kity.createClass("ViewDragger", {
_bind: function() {
var dragger = this,
isRootDrag = false,
isTempDrag = false,
lastPosition = null,
currentPosition = null;
this._minder.on('normal.mousedown readonly.mousedown readonly.touchstart', function(e) {
this._minder.on('normal.beforemousedown readonly.mousedown readonly.touchstart', function (e) {
e.originEvent.preventDefault(); // 阻止中键拉动
// 点击未选中的根节点临时开启
if (e.getTargetNode() == this.getRoot()) {
if (e.getTargetNode() == this.getRoot() || e.originEvent.button == 2) {
lastPosition = e.getPosition();
isRootDrag = true;
isTempDrag = true;
}
})
.on('normal.mousemove normal.touchmove', function(e) {
if (!isRootDrag) return;
if (!isTempDrag) return;
var offset = kity.Vector.fromPoints(lastPosition, e.getPosition());
if (offset.length() > 3) this.setStatus('hand');
})
......@@ -68,10 +69,13 @@ var ViewDragger = kity.createClass("ViewDragger", {
lastPosition = null;
// 临时拖动需要还原状态
if (isRootDrag) {
if (isTempDrag) {
dragger.setEnabled(false);
isRootDrag = false;
this.rollbackStatus();
isTempDrag = false;
var me = this;
setTimeout(function () {
me.rollbackStatus();
});
}
});
}
......@@ -155,11 +159,10 @@ KityMinder.registerModule('View', function() {
e.preventDefault();
}
},
mousewheel: function(e) {
mousewheel: function (e) {
var dx, dy;
e = e.originEvent;
if (e.ctrlKey || e.shiftKey) return;
if ('wheelDeltaX' in e) {
dx = e.wheelDeltaX || 0;
......
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