Browse Source

Fixed toolbars on component move

pull/2524/head
Artur Arseniev 7 years ago
parent
commit
fb3f47c1fb
  1. 17
      src/commands/view/SelectComponent.js

17
src/commands/view/SelectComponent.js

@ -57,7 +57,7 @@ export default {
}; };
em[method]('component:toggled', this.onSelect, this); em[method]('component:toggled', this.onSelect, this);
em[method]('change:componentHovered', this.onHovered, this); em[method]('change:componentHovered', this.onHovered, this);
em[method]('component:update', this.updateAttached, this); em[method]('component:update', this.onComponentUpdate, this);
em[method]('component:resize', this.updateAttached, this); em[method]('component:resize', this.updateAttached, this);
em[method]('change:canvasOffset', this.updateAttached, this); em[method]('change:canvasOffset', this.updateAttached, this);
// const body = this.getCanvasBody(); // const body = this.getCanvasBody();
@ -126,13 +126,11 @@ export default {
* @param {Object} el * @param {Object} el
* @private * @private
* */ * */
onSelect() { onSelect: debounce(function() {
const { em } = this; const { em } = this;
const component = em.getSelected(); const component = em.getSelected();
console.log('onSelect', { component });
const currentFrame = em.get('currentFrame') || {}; const currentFrame = em.get('currentFrame') || {};
const prevComp = this.getElSelected().component;
if (component && component === prevComp) return;
const view = component && component.getView(currentFrame.model); const view = component && component.getView(currentFrame.model);
let el = view && view.el; let el = view && view.el;
let result = {}; let result = {};
@ -141,7 +139,7 @@ export default {
const pos = this.getElementPos(el); const pos = this.getElementPos(el);
result = { el, pos, component, view: getViewEl(el) }; result = { el, pos, component, view: getViewEl(el) };
} }
console.log('onSelect', { result });
this.elSelected = result; this.elSelected = result;
this.updateToolsGlobal(); this.updateToolsGlobal();
@ -153,7 +151,7 @@ export default {
// } else { // } else {
// this.editor.stopCommand('resize'); // this.editor.stopCommand('resize');
// } // }
}, }),
getElHovered() { getElHovered() {
return this.elHovered || {}; return this.elHovered || {};
@ -752,6 +750,11 @@ export default {
this.updateToolsGlobal(); this.updateToolsGlobal();
}), }),
onComponentUpdate: debounce(function() {
console.log('onComponentUpdate', arguments);
this.onSelect();
}),
/** /**
* Returns element's data info * Returns element's data info
* @param {HTMLElement} el * @param {HTMLElement} el

Loading…
Cancel
Save