Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
Small correction to adjacent weight priority
Browse files Browse the repository at this point in the history
  • Loading branch information
asgvard committed May 10, 2019
1 parent 9b42245 commit f67a0cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion dist/spatialNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 5 additions & 1 deletion src/spatialNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit f67a0cb

Please sign in to comment.