Commit f95f1796 authored by campaign's avatar campaign

改进history的性能

parent ead205d7
......@@ -77,6 +77,7 @@ KityMinder.registerModule( "TextEditModule", function () {
if ( this.isSingleSelect() && node.isSelected()) {// && e.kityEvent.targetShape.getType().toLowerCase()== 'text'
sel.collapse();
sel.setSelectionShowStatus(true);
node.getTextShape().setStyle('cursor','text');
km.setStatus('textedit');
receiver.setTextEditStatus(true)
......@@ -112,6 +113,7 @@ KityMinder.registerModule( "TextEditModule", function () {
var nativeRange = range.nativeSel.getRangeAt(0);
if(nativeRange && (nativeRange.startContainer === receiver.container || receiver.container.contains(nativeRange.startContainer ))){
km.setStatus('textedit');
sel.setSelectionShowStatus(true);
km.fire('saveScene');
}
......@@ -127,14 +129,13 @@ KityMinder.registerModule( "TextEditModule", function () {
var orgEvt = e.originEvent,keyCode = orgEvt.keyCode;
if(keymap.isSelectedNodeKey[keyCode] && km.getStatus() != 'textedit' && !orgEvt.ctrlKey && !orgEvt.metaKey && !orgEvt.shiftKey && !orgEvt.altKey){
//准备输入状态
var textShape = node.getTextShape();
sel.setHide();
sel.setStartOffset(0);
sel.setEndOffset(textShape.getContent().length);
sel.setSelectionShowStatus(true);
receiver.setTextEditStatus(true)
.setSelection(sel)
.setKityMinder(this)
......@@ -237,7 +238,7 @@ KityMinder.registerModule( "TextEditModule", function () {
sel.setHide();
sel.setStartOffset(0);
sel.setEndOffset(textShape.getContent().length);
sel.setSelectionShowStatus(false);
receiver.setTextEditStatus(true)
.setSelection(sel)
.setKityMinder(this)
......@@ -249,6 +250,7 @@ KityMinder.registerModule( "TextEditModule", function () {
.setSelectionHeight()
.setContainerTxt(textShape.getContent())
.updateRange(range).setTextEditStatus(true);
km.setStatus('normal');
sel.setData('relatedNode',node);
}else {
......
......@@ -112,11 +112,15 @@ Minder.Receiver = kity.createClass( 'Receiver', {
me.updateTextData();
me.updateIndex();
me.updateSelection();
me.timer = setTimeout( function () {
if( me.selection.getSelectionShowStatus()) {
me.updateSelection();
me.timer = setTimeout(function () {
me.selection.setShow()
}, 500 );
}, 500)
}
}
var isTypeText = false;
var isKeypress = false;
......@@ -379,7 +383,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
var lastOffset = this.textData[ this.textData.length - 1 ];
width = lastOffset.x - startOffset.x + lastOffset.width;
} catch ( e ) {
console.log( 'e' )
console.log( e )
}
} else {
......@@ -404,4 +408,5 @@ Minder.Receiver = kity.createClass( 'Receiver', {
this.container.textContent = txt;
return this;
}
} );
\ No newline at end of file
......@@ -15,6 +15,7 @@ Minder.Selection = kity.createClass( 'Selection', {
this.setOpacity(0.5);
this.setStyle('cursor','text');
this._show = false;
this.selectionShowStatus = true;
},
collapse : function(toEnd){
......@@ -103,6 +104,7 @@ Minder.Selection = kity.createClass( 'Selection', {
var me = this,
state = '';
me.setStyle( 'display', '' );
this.setSelectionShowStatus(true);
me._show = true;
if(this.collapsed){
me.setOpacity(1);
......@@ -133,5 +135,11 @@ Minder.Selection = kity.createClass( 'Selection', {
},
updatePosition: function ( index ) {
},
setSelectionShowStatus:function(status){
this.selectionShowStatus = status;
},
getSelectionShowStatus:function(){
return this.selectionShowStatus
}
} );
\ No newline at end of file
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