From f3e93176b9049747774ec516e5e1ba56894add34 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Thu, 11 Jul 2019 18:14:06 +0000 Subject: [PATCH] Safari fixes --- Architype.js | 6 +++++- LayoutGroup.js | 2 +- LayoutLink.js | 27 ++++++++++++++------------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Architype.js b/Architype.js index afbe2a3..a4f11eb 100644 --- a/Architype.js +++ b/Architype.js @@ -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); diff --git a/LayoutGroup.js b/LayoutGroup.js index 51259fc..f5110f6 100644 --- a/LayoutGroup.js +++ b/LayoutGroup.js @@ -17,7 +17,7 @@ class LayoutGroup { for (let node of this.nodes) { for (let i of [0, 1]) { this.vec[i] += node.vec[i]; - }; + } } } diff --git a/LayoutLink.js b/LayoutLink.js index 19f196e..e626b8e 100644 --- a/LayoutLink.js +++ b/LayoutLink.js @@ -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) {