Browse Source

Fix SwitchVisibility

pull/5214/head
Artur Arseniev 3 years ago
parent
commit
2dcc5b0ca7
  1. 2
      src/canvas/view/FrameView.ts
  2. 11
      src/commands/view/SwitchVisibility.ts
  3. 2
      src/editor/model/Editor.ts

2
src/canvas/view/FrameView.ts

@ -19,6 +19,7 @@ export default class FrameView extends ModuleView<Frame, HTMLIFrameElement> {
} }
dragging = false; dragging = false;
loaded = false;
droppable?: Droppable; droppable?: Droppable;
rect?: DOMRect; rect?: DOMRect;
@ -456,6 +457,7 @@ export default class FrameView extends ModuleView<Frame, HTMLIFrameElement> {
this.droppable = new Droppable(em, this.wrapper?.el); this.droppable = new Droppable(em, this.wrapper?.el);
} }
model.trigger('loaded'); model.trigger('loaded');
this.loaded = true;
} }
_toggleEffects(enable: boolean) { _toggleEffects(enable: boolean) {

11
src/commands/view/SwitchVisibility.ts

@ -20,18 +20,23 @@ export default {
if (!ed.Commands.isActive('preview')) { if (!ed.Commands.isActive('preview')) {
const cv = ed.Canvas; const cv = ed.Canvas;
const mth = active ? 'on' : 'off'; const mth = active ? 'on' : 'off';
const canvasModel = cv.getModel();
cv.getFrames().forEach(frame => this._upFrame(frame, active)); cv.getFrames().forEach(frame => this._upFrame(frame, active));
cv.getModel()[mth]('change:frames', this._onFramesChange); canvasModel[mth]('change:frames', this._onFramesChange);
} }
}, },
_onFramesChange(m: any, frames: Frame[]) { _onFramesChange(m: any, frames: Frame[]) {
frames.forEach(frame => frame.once('loaded', () => this._upFrame(frame, true))); frames.forEach(frame => {
const load = () => this._upFrame(frame, true);
frame.view?.loaded ? load() : frame.once('loaded', load);
});
}, },
_upFrame(frame: Frame, active: boolean) { _upFrame(frame: Frame, active: boolean) {
const method = active ? 'add' : 'remove'; const method = active ? 'add' : 'remove';
frame.view?.getBody().classList[method](`${this.ppfx}dashed`); const cls = `${this.ppfx}dashed`;
frame.view?.getBody().classList[method](cls);
}, },
} as CommandObject< } as CommandObject<
{}, {},

2
src/editor/model/Editor.ts

@ -837,7 +837,7 @@ export default class EditorModel extends Model {
* @private * @private
*/ */
runDefault(opts = {}) { runDefault(opts = {}) {
var command = this.get('Commands').get(this.config.defaultCommand); const command = this.get('Commands').get(this.config.defaultCommand);
if (!command || this.defaultRunning) return; if (!command || this.defaultRunning) return;
command.stop(this, this, opts); command.stop(this, this, opts);
command.run(this, this, opts); command.run(this, this, opts);

Loading…
Cancel
Save