From 399e638572304e04c688be12a2dd5f7152fb6928 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Mon, 8 Mar 2021 02:41:29 +0100 Subject: [PATCH] Update switch visibility command for multi page --- src/commands/view/SwitchVisibility.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/commands/view/SwitchVisibility.js b/src/commands/view/SwitchVisibility.js index 9b853b3a4..80a30a790 100644 --- a/src/commands/view/SwitchVisibility.js +++ b/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`); } };