Commit 6a5d1086 authored by techird's avatar techird

optimize root drag

parent 4fe36697
...@@ -27,21 +27,21 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -27,21 +27,21 @@ var ViewDragger = kity.createClass( "ViewDragger", {
lastPosition = null, lastPosition = null,
currentPosition = null; currentPosition = null;
this._minder.on( 'normal.beforemousedown readonly.beforemousedown readonly.beforetouchstart', function ( e ) { this._minder.on( 'normal.mousedown readonly.mousedown readonly.touchstart', function ( e ) {
// 点击未选中的根节点临时开启 // 点击未选中的根节点临时开启
if ( e.getTargetNode() == this.getRoot() && if ( e.getTargetNode() == this.getRoot() &&
( !this.getRoot().isSelected() || !this.isSingleSelect() ) ) { ( !this.getRoot().isSelected() || !this.isSingleSelect() ) ) {
lastPosition = e.getPosition(); lastPosition = e.getPosition();
dragger.setEnabled( true );
isRootDrag = true; isRootDrag = true;
e.originEvent.preventDefault();
var me = this;
setTimeout( function () {
me.setStatus( 'hand' );
}, 1 );
} }
} ) } )
.on('normal.mousemove normal.touchmove', function (e) {
if (!isRootDrag) return;
var offset = kity.Vector.fromPoints( lastPosition, e.getPosition());
if (offset.length() > 10) this.setStatus( 'hand' );
})
.on( 'hand.beforemousedown hand.beforetouchend', function ( e ) { .on( 'hand.beforemousedown hand.beforetouchend', function ( e ) {
// 已经被用户打开拖放模式 // 已经被用户打开拖放模式
if ( dragger.isEnabled() ) { if ( dragger.isEnabled() ) {
...@@ -64,7 +64,7 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -64,7 +64,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
} }
} ) } )
.on( 'hand.mouseup', function ( e ) { .on( 'mouseup', function ( e ) {
lastPosition = null; lastPosition = null;
// 临时拖动需要还原状态 // 临时拖动需要还原状态
......
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