Spatial Navigation for GeckoView - v3.2.0
    Preparing search index...

    Variable SCORING_CONSTANTSConst

    SCORING_CONSTANTS: {
        ALIGNMENT_BASE: 10;
        ALIGNMENT_DECAY_PX: 50;
        CONE_TOLERANCE_BASE_PX: 4;
        CONE_TOLERANCE_RATIO: 3;
        DIFFERENT_SCROLL_PENALTY: 75;
        EDGE_EPS_BASE: 4;
        EPSILON: 1;
        FORWARD_OVERLAP_TOLERANCE_PX: 12;
        GRID_BONUS: 500;
        GROUP_ENTER_LAST_BONUS: 1000;
        OFFSCREEN_PENALTY: 120;
        PRIMARY_WEIGHT: 1000;
        PROJECTED_SECONDARY_WEIGHT: 0.5;
        SAME_GROUP_BONUS: 2000;
        SAME_SCROLL_BONUS: 150;
    } = ...

    Score-weight constants used by the scoring algorithm.

    The implicit hierarchy is intentional:

    SAME_GROUP_BONUS (2000) > GROUP_ENTER_LAST_BONUS (1000) > GRID_BONUS (500) > SAME_SCROLL_BONUS (150) > OFFSCREEN_PENALTY (120) > DIFFERENT_SCROLL_PENALTY (75)

    "Stay in the same focus group" outranks every other consideration so users don't spuriously jump out of a logical region (sidebar, modal, list). Inside the same group, grid alignment beats scroll-container co-location, and the smaller scroll-related nudges only act as tiebreakers between otherwise equivalent candidates.

    If you tune these, the test suite in __tests__/scoring.test.ts exercises the boundaries — keep that suite green.

    Type Declaration

    • ReadonlyALIGNMENT_BASE: 10

      Alignment baseline — perfect alignment scores this.

    • ReadonlyALIGNMENT_DECAY_PX: 50

      Alignment decay rate (px). Larger = more forgiving.

    • ReadonlyCONE_TOLERANCE_BASE_PX: 4

      Off-axis spread allowed inside the navigation cone, base value (px).

    • ReadonlyCONE_TOLERANCE_RATIO: 3

      Off-axis spread is also bounded by primary * CONE_TOLERANCE_RATIO.

    • ReadonlyDIFFERENT_SCROLL_PENALTY: 75

      Penalty (added) when candidate is in a different scroll container.

    • ReadonlyEDGE_EPS_BASE: 4

      Allowed overlap when checking strict-edge containment (px, before adding overlapThreshold).

    • ReadonlyEPSILON: 1

      Tiny epsilon for float comparisons (px).

    • ReadonlyFORWARD_OVERLAP_TOLERANCE_PX: 12

      When allowOverlap is true, candidates may overlap the current element by this many pixels in the navigation axis (before adding overlapThreshold).

    • ReadonlyGRID_BONUS: 500

      Bonus (subtracted from score) when a grid-aligned candidate is found in grid mode.

    • ReadonlyGROUP_ENTER_LAST_BONUS: 1000

      Bonus (subtracted) when entering a group via its remembered last-focused element.

    • ReadonlyOFFSCREEN_PENALTY: 120

      Penalty (added) when candidate is off-screen.

    • ReadonlyPRIMARY_WEIGHT: 1000

      Score weight applied to primary-axis distance — dominant factor in the linear score.

    • ReadonlyPROJECTED_SECONDARY_WEIGHT: 0.5

      Projected-distance secondary axis weight (lower = strongly prefer aligned candidates).

    • ReadonlySAME_GROUP_BONUS: 2000

      Bonus (subtracted) when candidate is in the same focus group as the current element.

    • ReadonlySAME_SCROLL_BONUS: 150

      Bonus (subtracted) when candidate shares the current element's scroll container.