Commit 6eb7941b authored by techird's avatar techird

fix performance issue

parent edaec00e
...@@ -29,18 +29,24 @@ KM.registerToolbarUI('template theme', function(name) { ...@@ -29,18 +29,24 @@ KM.registerToolbarUI('template theme', function(name) {
$combox.appendTo(me.$container.find('.kmui-dialog-container')); $combox.appendTo(me.$container.find('.kmui-dialog-container'));
} }
}); });
var lastState, lastValue;
//状态反射 //状态反射
me.on('interactchange', function() { me.on('interactchange', function() {
var state = this.queryCommandState(name), var state = this.queryCommandState(name),
value = this.queryCommandValue(name); value = this.queryCommandValue(name);
//设置按钮状态 //设置按钮状态
comboboxWidget.button().kmui().disabled(state == -1).active(state == 1); if (lastState != state)
comboboxWidget.button().kmui().disabled(state == -1).active(state == 1);
if (value) { if (value && value != lastValue) {
// 此处貌似性能很差,加入缓存
comboboxWidget.selectItemByValue(value); comboboxWidget.selectItemByValue(value);
} }
lastState = state;
lastValue = value;
}); });
return comboboxWidget.button().addClass('kmui-combobox'); return comboboxWidget.button().addClass('kmui-combobox');
......
...@@ -29,17 +29,23 @@ KM.registerToolbarUI( 'zoom', function ( name ) { ...@@ -29,17 +29,23 @@ KM.registerToolbarUI( 'zoom', function ( name ) {
$combox.appendTo( me.$container.find( '.kmui-dialog-container' ) ); $combox.appendTo( me.$container.find( '.kmui-dialog-container' ) );
} }
} ); } );
var lastState, lastValue;
//状态反射 //状态反射
me.on( 'interactchange', function () { me.on( 'interactchange', function () {
var state = this.queryCommandState( name ), var state = this.queryCommandState( name ),
value = this.queryCommandValue( name ); value = this.queryCommandValue( name );
//设置按钮状态
comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 ); if (state != lastState) {
if ( value ) { //设置按钮状态
comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 );
}
if ( value && value != lastValue ) {
//设置label //设置label
comboboxWidget.selectItemByLabel( value + '%' ); comboboxWidget.selectItemByLabel( value + '%' );
} }
lastState = state;
lastValue = value;
} ); } );
//comboboxWidget.button().kmui().disabled(-1); //comboboxWidget.button().kmui().disabled(-1);
......
...@@ -209,7 +209,8 @@ kity.extendClass(Minder, { ...@@ -209,7 +209,8 @@ kity.extendClass(Minder, {
.start(node, duration, 'ease') .start(node, duration, 'ease')
.on('finish', function() { .on('finish', function() {
// 可能性能低的时候会丢帧 // 可能性能低的时候会丢帧
setTimeout(function() { clearTimeout(node._lastFixTimeout);
node._lastFixTimeout = setTimeout(function() {
applyMatrix(node, matrix); applyMatrix(node, matrix);
me.fire('layoutfinish', { me.fire('layoutfinish', {
node: node, node: node,
......
...@@ -52,7 +52,11 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -52,7 +52,11 @@ Minder.Receiver = kity.createClass('Receiver', {
textShape = new kity.Text(); textShape = new kity.Text();
} }
this.textShape = textShape; this.textShape = textShape;
this.container.innerHTML = utils.unhtml(textShape.getContent()); // techird: add cache
if (textShape._lastContent != textShape.getContent()) {
this.container.innerHTML = utils.unhtml(textShape.getContent());
textShape._lastContent = textShape.getContent();
}
return this; return this;
}, },
setTextShapeSize: function(size) { setTextShapeSize: function(size) {
...@@ -132,7 +136,7 @@ Minder.Receiver = kity.createClass('Receiver', { ...@@ -132,7 +136,7 @@ Minder.Receiver = kity.createClass('Receiver', {
me.minderNode.getRenderContainer().bringTop(); me.minderNode.getRenderContainer().bringTop();
me.minderNode.render(); me.minderNode.render();
//移动光标不做layout //移动光标不做layout
if(!keymap.direction[keyCode]){ if(!keymap.direction[keyCode] && !orgEvt.shiftKey && !orgEvt.metaKey && orgEvt.ctrlKey){
clearTimeout(me.inputTextTimer); clearTimeout(me.inputTextTimer);
me.inputTextTimer = setTimeout(function(){ me.inputTextTimer = setTimeout(function(){
......
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