Browse Source

Update switch visibility command for multi page

pull/3411/head
Artur Arseniev 5 years ago
parent
commit
399e638572
  1. 23
      src/commands/view/SwitchVisibility.js

23
src/commands/view/SwitchVisibility.js

@ -1,4 +1,10 @@
import { bindAll } from 'underscore';
export default {
init() {
bindAll(this, '_onFramesChange');
},
run(ed) {
this.toggleVis(ed);
},
@ -9,11 +15,18 @@ export default {
toggleVis(ed, active = 1) {
if (!ed.Commands.isActive('preview')) {
const method = active ? 'add' : 'remove';
ed.Canvas.getFrames().forEach(frame => {
frame.view.getBody().classList[method](`${this.ppfx}dashed`);
});
const cvModel = ed.Canvas.getCanvasView().model;
ed.Canvas.getFrames().forEach(frame => this._upFrame(frame, active));
cvModel[active ? 'on' : 'off']('change:frames', this._onFramesChange);
}
},
_onFramesChange(m, frames) {
frames.forEach(frame => this._upFrame(frame, 1));
},
_upFrame(frame, active) {
const method = active ? 'add' : 'remove';
frame.view.getBody().classList[method](`${this.ppfx}dashed`);
}
};

Loading…
Cancel
Save