Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add navigation history to subcircuit click event #101

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class Circuit extends HeadlessCircuit {
});
}
displayOn(elem) {
return this._makePaper(elem, this._graph);
return this._makePaper(elem, this._graph, null);
}
scaleAndRefreshPaper(paper, scale) {
paper.scale(Math.pow(1.1, scale));
Expand All @@ -156,7 +156,13 @@ export class Circuit extends HeadlessCircuit {
graph.resetCells(graph.getCells());
paper.unfreeze();
}
_makePaper(elem, graph) {
_makePaper(elem, graph, parentModel) {
if (!parentModel) {
parentModel = graph;
parentModel.set("parent", null);
parentModel.set("isTopLevel", true);
}

this._engine.observeGraph(graph);
const opts = _.merge({ el: elem, model: graph }, paperOptions);
const paper = new joint.dia.Paper(opts);
Expand Down Expand Up @@ -212,7 +218,7 @@ export class Circuit extends HeadlessCircuit {
// Create and set up paper
const pdiv = $('<div>').appendTo(subcircuitModal);
const graph = model.get('graph');
const paper = this._makePaper(pdiv, graph);
const paper = this._makePaper(pdiv, graph, model);
paper.once('render:done', () => {
this._windowCallback('Subcircuit', subcircuitModal, () => {
this._engine.unobserveGraph(graph);
Expand All @@ -221,8 +227,11 @@ export class Circuit extends HeadlessCircuit {
});
});

// Create buttons
model.set("zoomLevel", 0);
model.set("parent", parentModel);
model.set("isTopLevel", false);

// Create buttons
const buttonGroup = $('<div class="btn-group"></div>')
for (const button of this._subcircuitButtons) {
$('<button class="btn btn-secondary"></button>')
Expand Down
Loading