-
Notifications
You must be signed in to change notification settings - Fork 642
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
[css-nav-1] Tweak the distance function to prioritize elements that are aligned #3388
Comments
Migrated from WICG/spatial-navigation#122 (comment) Probably an edge case worth noting that a horizontally equally sized multiple fragment would need to be handled by using the centroid of the vertical extremas. |
Migrated from WICG/spatial-navigation#122 (comment) @hugoholgersson I've been also considering the case that you described above. In your example, if the user presses the down arrow key, from the "XXXXXXX" fragment in the second line the distance value will be calculated. |
Migrated from WICG/spatial-navigation#122 (comment)
We risk a "dead end" when a smaller focusable A sits centered, on top (z-wise) of a bigger focusable B, A->B->A->B->A ... ? |
Migrated from WICG/spatial-navigation#122 (comment) I've tried a quick and dirty prototype that computes the delta between the desired direction's reference angle and the angle between the currently focused element's centroid and the candidate element's centroid with an arctangent2, and it seems to improve performance a bit. @jihyerish knows how the strawman algorithm works, but the weights and magnitude have to be scaled to match the other ABCD scores in the distance computation phase. Whether or not you factor this in is entirely up to you, but it seems to help. |
Migrated from WICG/spatial-navigation#122 (comment) @cynthia could you give an ASCII example? (How do you define "vertical extremas"?) I can imagine one case where a focusable, C, becomes unreachable (?) when going up/down between A and B:
|
Migrated from WICG/spatial-navigation#122 (comment) Taking the centroid of that fragment, you mean? |
Migrated from WICG/spatial-navigation#122 (comment) @hugoholgersson Yes. Because of that, it needs to be defined which fragment to take depending on the input direction. |
Migrated from WICG/spatial-navigation#122 (comment) I also like the idea of calculating the distances between elements' centroids. But how do we define the centroid of inline elements that span a line break (i.e non-rectangular elements)?
|
Migrated from WICG/spatial-navigation#122 (comment) @hugoholgersson I've been also considering the case that you described above. In your example, if the user presses the down arrow key, from the "XXXXXXX" fragment in the second line the distance value will be calculated. |
While investigating how to improve the distance formula in the spec, I noticed that prioritizing elements that are with the currently focused element can be solved by removing the B factor of the formula. But there still remains ambiguity when there are more than one aligned elements with the currently focused element. Therefore, to solve this problem, I'd like to suggest adding a new factor for calculating the degree of alignment between a candidate and the search origin. The factor is calculated as
See more information in here. For overall improvement of the distance formula, I suggest the changes in the issue #3384. |
Fix the mistake about `alignBias` definition depending on the original proposal. (+ Remove trailing spaces) Reference: - https://wicg.github.io/spatial-navigation/tests/ux/result.html#2-add-the-factor-about-calculating-the-degree-of-alignment-between-a-candidate-and-the-search-origin - #3388 (comment)
Migrated from WICG/spatial-navigation#122
Originally created by @frivoal on Wed, 17 Oct 2018 05:33:36 GMT
The current distance function behaves somewhat strangely, mostly due to:
B
factor in the formula penalizes elements which are aligned, in a way that is not fully compensated byC
. Both in combination seem to favor elements at 0 or 90 degrees over those at 45 degrees, which does not seem justified.We should:
The text was updated successfully, but these errors were encountered: