Commit 60274548 authored by techird's avatar techird

fix view issue

parent 1a359409
...@@ -28,8 +28,11 @@ var ViewDragger = kity.createClass("ViewDragger", { ...@@ -28,8 +28,11 @@ var ViewDragger = kity.createClass("ViewDragger", {
lastPosition = null, lastPosition = null,
currentPosition = null; currentPosition = null;
this._minder.on('normal.mousedown readonly.mousedown readonly.touchstart', function (e) { this._minder.on('normal.mousedown normal.touchstart readonly.mousedown readonly.touchstart', function(e) {
e.originEvent.preventDefault(); // 阻止中键拉动
if (e.originEvent.button == 2) {
e.originEvent.preventDefault(); // 阻止中键拉动
}
// 点击未选中的根节点临时开启 // 点击未选中的根节点临时开启
if (e.getTargetNode() == this.getRoot() || e.originEvent.button == 2) { if (e.getTargetNode() == this.getRoot() || e.originEvent.button == 2) {
lastPosition = e.getPosition(); lastPosition = e.getPosition();
...@@ -37,18 +40,19 @@ var ViewDragger = kity.createClass("ViewDragger", { ...@@ -37,18 +40,19 @@ var ViewDragger = kity.createClass("ViewDragger", {
} }
}) })
.on('normal.mousemove normal.touchmove', function(e) { .on('normal.mousemove normal.touchmove readonly.touchmove readonly.mousemove', function(e) {
if (!isTempDrag) return; if (!isTempDrag) return;
var offset = kity.Vector.fromPoints(lastPosition, e.getPosition()); var offset = kity.Vector.fromPoints(lastPosition, e.getPosition());
if (offset.length() > 3) this.setStatus('hand'); if (offset.length() > 3) this.setStatus('hand');
}) })
.on('hand.beforemousedown hand.beforetouchend', function(e) { .on('hand.beforemousedown hand.beforetouchstart', function(e) {
// 已经被用户打开拖放模式 // 已经被用户打开拖放模式
if (dragger.isEnabled()) { if (dragger.isEnabled()) {
lastPosition = e.getPosition(); lastPosition = e.getPosition();
e.stopPropagation(); e.stopPropagation();
} }
console.log('touchstart');
}) })
.on('hand.beforemousemove hand.beforetouchmove', function(e) { .on('hand.beforemousemove hand.beforetouchmove', function(e) {
...@@ -65,7 +69,7 @@ var ViewDragger = kity.createClass("ViewDragger", { ...@@ -65,7 +69,7 @@ var ViewDragger = kity.createClass("ViewDragger", {
} }
}) })
.on('mouseup', function(e) { .on('mouseup touchend', function(e) {
lastPosition = null; lastPosition = null;
// 临时拖动需要还原状态 // 临时拖动需要还原状态
...@@ -86,8 +90,7 @@ KityMinder.registerModule('View', function() { ...@@ -86,8 +90,7 @@ KityMinder.registerModule('View', function() {
base: Command, base: Command,
execute: function(minder) { execute: function(minder) {
minder._viewDragger.setEnabled(!minder._viewDragger.isEnabled()); if (minder.getStatus() != 'hand') {
if (minder._viewDragger.isEnabled()) {
minder.setStatus('hand'); minder.setStatus('hand');
} else { } else {
minder.rollbackStatus(); minder.rollbackStatus();
...@@ -96,7 +99,7 @@ KityMinder.registerModule('View', function() { ...@@ -96,7 +99,7 @@ KityMinder.registerModule('View', function() {
}, },
queryState: function(minder) { queryState: function(minder) {
return minder._viewDragger.isEnabled() ? 1 : 0; return minder.getStatus() == 'hand' ? 1 : 0;
}, },
enableReadOnly: false enableReadOnly: false
}); });
...@@ -156,7 +159,10 @@ KityMinder.registerModule('View', function() { ...@@ -156,7 +159,10 @@ KityMinder.registerModule('View', function() {
e.preventDefault(); e.preventDefault();
} }
}, },
mousewheel: function (e) { statuschange: function(e) {
this._viewDragger.setEnabled(e.currentStatus == 'hand');
},
mousewheel: function(e) {
var dx, dy; var dx, dy;
e = e.originEvent; e = e.originEvent;
if (e.ctrlKey || e.shiftKey) return; if (e.ctrlKey || e.shiftKey) return;
......
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