Browse Source

Enable SelectComponent for multi-frames

pull/2524/head
Artur Arseniev 7 years ago
parent
commit
b56efdfe51
  1. 1
      src/canvas/view/FrameView.js
  2. 21
      src/commands/view/SelectComponent.js

1
src/canvas/view/FrameView.js

@ -31,6 +31,7 @@ export default Backbone.View.extend({
this.listenTo(model, 'change:x change:y', this.updatePos); this.listenTo(model, 'change:x change:y', this.updatePos);
this.listenTo(this.em, 'change:device', this.updateDim); this.listenTo(this.em, 'change:device', this.updateDim);
this.updatePos(); this.updatePos();
model.view = this;
}, },
updatePos(md) { updatePos(md) {

21
src/commands/view/SelectComponent.js

@ -48,12 +48,21 @@ export default {
const methods = { on, off }; const methods = { on, off };
const body = this.getCanvasBody(); const body = this.getCanvasBody();
const win = this.getContentWindow(); const win = this.getContentWindow();
methods[method](body, 'mouseover', this.onHover); const trigger = (win, body) => {
methods[method](body, 'mouseout', this.onOut); methods[method](body, 'mouseover', this.onHover);
methods[method](body, 'click touchend', this.onClick); methods[method](body, 'mouseout', this.onOut);
methods[method](win, 'scroll resize', this.onFrameScroll); methods[method](body, 'click touchend', this.onClick);
em[method]('component:toggled', this.onSelect, this); methods[method](win, 'scroll resize', this.onFrameScroll);
em[method]('change:componentHovered', this.onHovered, this); em[method]('component:toggled', this.onSelect, this);
em[method]('change:componentHovered', this.onHovered, this);
};
trigger(win, body);
em.get('Canvas')
.getFrames()
.forEach(frame => {
const { view } = frame;
trigger(view.getWindow(), view.getBody());
});
}, },
/** /**

Loading…
Cancel
Save