From 95af630439085818058040420e4b345dbce94b38 Mon Sep 17 00:00:00 2001 From: futpib Date: Wed, 21 Nov 2018 14:23:23 +0300 Subject: [PATCH] Keyboard left/right navigation tweak --- components/graph/index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/graph/index.js b/components/graph/index.js index 02a5cf1..4ea3139 100644 --- a/components/graph/index.js +++ b/components/graph/index.js @@ -23,6 +23,8 @@ const { repeat, sortBy, values, + scan, + range, } = require('ramda'); const React = require('react'); @@ -1208,11 +1210,12 @@ class Graph extends React.Component { return; } - const type0 = selected.type; - const type1 = selectionObjectTypes[direction]( - selectionObjectTypes.fromPulseType(type0), + const next = t => selectionObjectTypes[direction](t); + const types = scan( + next, + next(selectionObjectTypes.fromPulseType(selected.type)), + range(0, 3) ); - const type2 = selectionObjectTypes[direction](type1); const bestSelectionPredicate = x => null || x.source === selected.id || @@ -1221,10 +1224,7 @@ class Graph extends React.Component { selected.target === x.id; this.setState({ - selected: this._findAnyObjectForSelection([ - type1, - type2, - ], bestSelectionPredicate), + selected: this._findAnyObjectForSelection(types, bestSelectionPredicate), }); }