Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add configurable distance calculation methods #138

Merged
merged 4 commits into from
Aug 29, 2024

Conversation

Braggiouy
Copy link
Contributor

@Braggiouy Braggiouy commented Aug 1, 2024

Based on the following issue: → Wrong decision on distance measurement SpatialNavigation.ts :getSecondaryAxisDistance()

We wanted to improve the way on how we handle the algorithm that takes care of the distance calculation between two elements.

This implementation allows developers to choose the best method for navigating between focusable elements. Using corners is ideal for siblings of the same size, while the center method is better suited for siblings of varying sizes. Additionally, the edges option provides another method for edge-based distance calculations.

Quick summary :

  • Added a new initialization option distanceCalculationMethod in the init method. This option accepts three values: center, edges, and corners(default).
  • Updated the getSecondaryAxisDistance method to support different distance calculation methods.

Usage:

init({
  debug: false,
  visualDebug: false,
  distanceCalculationMethod: 'center',
  // other options
});

Working Demo With Asset sizing modifications :
distanceCalculationMethod: 'center'

Grabacion.de.pantalla.2024-08-05.a.las.10.15.49.mov

Feel free to add any improvement or suggestion to this implementation.

@Braggiouy Braggiouy added the enhancement New feature or request label Aug 1, 2024
@Braggiouy Braggiouy requested a review from a team August 1, 2024 12:03
@Braggiouy Braggiouy self-assigned this Aug 1, 2024
@Braggiouy Braggiouy changed the title Feat: Add Configurable Distance Calculation Methods Feat: Add configurable distance calculation methods Aug 1, 2024
@Braggiouy Braggiouy marked this pull request as draft August 5, 2024 08:50
Copy link
Collaborator

@predikament predikament left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks good to me - Especially that people can pass their custom function as needed.

Let's sort out the conflicts and get this change in.

@asgvard: Agreed?

@Braggiouy Braggiouy marked this pull request as ready for review August 21, 2024 08:29
Copy link
Collaborator

@asgvard asgvard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good 💯

@Braggiouy Braggiouy merged commit 0058b0f into main Aug 29, 2024
1 check passed
@Braggiouy Braggiouy deleted the bruno/PRO-146/comparison-origin-support branch September 26, 2024 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants