Browse Source

Rerender Component toolbar when necessary

pull/3217/head
Artur Arseniev 5 years ago
parent
commit
c24da9612a
  1. 9
      src/commands/view/SelectComponent.js
  2. 5
      src/dom_components/model/Component.js

9
src/commands/view/SelectComponent.js

@ -95,6 +95,7 @@ export default {
this.updateGlobalPos,
this
);
em[method]('component:update:toolbar', this._upToolbar, this);
em[method]('change:canvasOffset', this.updateAttached, this);
em[method]('frame:updated', this.onFrameUpdated, this);
em[method]('canvas:updateTools', this.onFrameUpdated, this);
@ -640,7 +641,11 @@ export default {
style.height = pos.height + unit;
},
updateToolsGlobal() {
_upToolbar: debounce(function() {
this.updateToolsGlobal({ force: 1 });
}),
updateToolsGlobal(opts = {}) {
const { el, pos, component } = this.getElSelected();
if (!el) {
@ -652,7 +657,7 @@ export default {
const { canvas } = this;
const isNewEl = this.lastSelected !== el;
if (isNewEl) {
if (isNewEl || opts.force) {
this.lastSelected = el;
this.updateToolbar(component);
}

5
src/dom_components/model/Component.js

@ -191,6 +191,7 @@ const Component = Backbone.Model.extend(Styleable).extend(
this.listenTo(this, 'change:tagName', this.tagUpdated);
this.listenTo(this, 'change:attributes', this.attrUpdated);
this.listenTo(this, 'change:attributes:id', this._idUpdated);
this.on('change:toolbar', this.__emitUpdateTlb);
this.set('status', '');
this.views = [];
this.__isSymbol() && this.__initSymb();
@ -209,6 +210,10 @@ const Component = Backbone.Model.extend(Styleable).extend(
}
},
__emitUpdateTlb() {
this.emitUpdate('toolbar');
},
/**
* Check component's type
* @param {string} type Component type

Loading…
Cancel
Save