From f67a0cb38bec482ebfbe90fde0f3066efe9bc147 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Fri, 10 May 2019 14:23:00 +0200 Subject: [PATCH] Small correction to adjacent weight priority --- dist/spatialNavigation.js | 6 +++++- src/spatialNavigation.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dist/spatialNavigation.js b/dist/spatialNavigation.js index d4562e1..b6b61ed 100644 --- a/dist/spatialNavigation.js +++ b/dist/spatialNavigation.js @@ -113,7 +113,11 @@ var SpatialNavigation = function () { * The higher this value is, the less prioritised the candidate is */ var totalDistancePoints = primaryAxisDistance * MAIN_COORDINATE_WEIGHT + secondaryAxisDistance; - var priority = totalDistancePoints / (isAdjacentSlice ? ADJACENT_SLICE_WEIGHT : DIAGONAL_SLICE_WEIGHT); + + /** + * + 1 here is in case of distance is zero, but we still want to apply Adjacent priority weight + */ + var priority = (totalDistancePoints + 1) / (isAdjacentSlice ? ADJACENT_SLICE_WEIGHT : DIAGONAL_SLICE_WEIGHT); _this.log('smartNavigate', 'distance (primary, secondary, total weighted) for ' + sibling.focusKey + ' relative to ' + focusKey + ' is', primaryAxisDistance, secondaryAxisDistance, totalDistancePoints); diff --git a/src/spatialNavigation.js b/src/spatialNavigation.js index f57acbb..b99bbd5 100644 --- a/src/spatialNavigation.js +++ b/src/spatialNavigation.js @@ -230,7 +230,11 @@ class SpatialNavigation { * The higher this value is, the less prioritised the candidate is */ const totalDistancePoints = (primaryAxisDistance * MAIN_COORDINATE_WEIGHT) + secondaryAxisDistance; - const priority = totalDistancePoints / (isAdjacentSlice ? ADJACENT_SLICE_WEIGHT : DIAGONAL_SLICE_WEIGHT); + + /** + * + 1 here is in case of distance is zero, but we still want to apply Adjacent priority weight + */ + const priority = (totalDistancePoints + 1) / (isAdjacentSlice ? ADJACENT_SLICE_WEIGHT : DIAGONAL_SLICE_WEIGHT); this.log( 'smartNavigate',