Fix addLine()

This commit is contained in:
Ian Gulliver
2019-07-04 04:40:46 +00:00
parent 22960e57b0
commit 353a209ea1
4 changed files with 276 additions and 136 deletions

View File

@@ -14,12 +14,6 @@ class Architype {
this.container_.appendChild(editorElem);
this.editor_ = new Editor(editorElem);
this.lines_ = document.createElement('div');
this.lines_.innerHTML = `<!--# include file="lines.svg" -->`;
this.lines_ = this.lines_.firstElementChild;
this.lines_.classList.add('gridLines');
this.lines_.classList.add('white');
this.grid_ = document.createElement('div');
this.grid_.classList.add('grid');
this.container_.appendChild(this.grid_);
@@ -160,18 +154,19 @@ class Architype {
}
}
// TODO: fix this
addLines(pos, cls) {
let lines = this.lines_.cloneNode(true);
lines.classList.add(cls);
lines.style.gridColumn = pos[0] + 1;
lines.style.gridRow = pos[1] + 1;
this.grid_.appendChild(lines);
return lines;
addLine(pos, cls) {
let svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svg.classList.add('gridLines');
svg.style.gridColumn = pos[0] + 1;
svg.style.gridRow = pos[1] + 1;
this.grid_.appendChild(svg);
let use = document.createElementNS('http://www.w3.org/2000/svg', 'use');
svg.appendChild(use);
use.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#' + cls);
}
}
<!--# include file="Editor.js" -->
<!--# include file="EditorEntryBase.js" -->
<!--# include file="EditorGroup.js" -->