Commit bbb1ea4e authored by campaign's avatar campaign

优化鼠标在节点外部时,选区依旧生效

parent f90cd952
......@@ -16,6 +16,8 @@ KityMinder.registerModule('TextEditModule', function() {
//当前是否有选区存在
var selectionReadyShow = false;
var mousedownNode;
function inputStatusReady(node){
if (node && km.isSingleSelect() && node.isSelected()) {
......@@ -91,6 +93,8 @@ KityMinder.registerModule('TextEditModule', function() {
if(node){
if (this.isSingleSelect() && node.isSelected()) {
mousedownNode = node;
var textGroup = node.getTextGroup();
textGroup.setStyle('cursor', 'default');
......@@ -158,6 +162,7 @@ KityMinder.registerModule('TextEditModule', function() {
var node = e.getTargetNode();
mousedownNode = null;
if (node && !selectionReadyShow && receiver.isReady()) {
......@@ -208,11 +213,13 @@ KityMinder.registerModule('TextEditModule', function() {
}
//ipad下不做框选
if (mouseDownStatus && receiver.isReady() && selectionReadyShow) {
var node = e.getTargetNode();
e.stopPropagationImmediately();
if(node){
var offset = e.getPosition(node.getRenderContainer());
if(node || mousedownNode){
var offset = e.getPosition(node ? node.getRenderContainer() : mousedownNode.getRenderContainer());
receiver
.updateSelectionByMousePosition(offset)
......
......@@ -220,7 +220,7 @@ Minder.Receiver = kity.createClass('Receiver', {
this.selection.setHeight((this.minderNode.getData('font-size') || this.minderNode.getStyle('font-size')) * 1);
return this;
},
updateSelectionByMousePosition: function(offset,dir) {
updateSelectionByMousePosition: function(offset) {
var me = this;
var result = 0;
......@@ -240,7 +240,6 @@ Minder.Receiver = kity.createClass('Receiver', {
result += i;
if (offset.x - v.x > v.width / 2) {
result += 1;
}
......@@ -257,6 +256,13 @@ Minder.Receiver = kity.createClass('Receiver', {
return false;
}else{
if(first.y > offset.y && l === 0){
result = 0;
return false;
}else if(l == me.textData.length - 1 && first.y + lineHeight < offset.y){
result += arr.length + 1;
return false;
}
result += arr.length + (arr.length == 1 && arr[0].width === 0 ? 0 : 1);
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