Safari fixes

This commit is contained in:
Ian Gulliver
2019-07-11 18:14:06 +00:00
parent 2cbaade0d5
commit f3e93176b9
3 changed files with 20 additions and 15 deletions

View File

@@ -1,5 +1,9 @@
'use strict';
addEventListener('error', (e) => {
console.log(e);
});
class Architype {
constructor(container) {
this.container_ = container;
@@ -25,7 +29,7 @@ class Architype {
this.drawGeneration_ = -1;
this.render_ = [];
for (let i = 0; i < navigator.hardwareConcurrency; ++i) {
for (let i = 0; i < (navigator.hardwareConcurrency || 2); ++i) {
let render = new Worker('render.js');
render.addEventListener('message', (e) => { this.onRender(e); });
this.render_.push(render);

View File

@@ -17,7 +17,7 @@ class LayoutGroup {
for (let node of this.nodes) {
for (let i of [0, 1]) {
this.vec[i] += node.vec[i];
};
}
}
}

View File

@@ -8,6 +8,19 @@ class LayoutLink {
this.nodesByPos_ = nodesByPos;
this.linksByPos_ = linksByPos;
this.labelsByPos_ = labelsByPos;
// Mapping to lines.svg clock-style numbering
this.outPointLookup_ = new StringMap([
[[ 0,-1], 0],
[[ 1,-1], 1],
[[ 1, 0], 2],
[[ 1, 1], 3],
[[ 0, 1], 4],
[[-1, 1], 5],
[[-1, 0], 6],
[[-1,-1], 7],
]);
this.bfs();
}
@@ -99,18 +112,6 @@ class LayoutLink {
}
}
// Mapping to lines.svg clock-style numbering
outPointLookup = new StringMap([
[[ 0,-1], 0],
[[ 1,-1], 1],
[[ 1, 0], 2],
[[ 1, 1], 3],
[[ 0, 1], 4],
[[-1, 1], 5],
[[-1, 0], 6],
[[-1,-1], 7],
]);
getCost(from, to) {
// Only handles adjacent positions
@@ -175,7 +176,7 @@ class LayoutLink {
to[0] - from[0],
to[1] - from[1],
];
return this.outPointLookup.get(offset);
return this.outPointLookup_.get(offset);
}
getInPoint(from, to) {