-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add PoC for markup-guided focus shifting lib #1
Conversation
Traversing is the way.
Changed things up to be able to mostly pass a check with tsc --noEmit --allowJs --checkJs --lib es2023,dom index.js
- Just use the group attribute to announce the strategy. - Rename 'mute' to 'skip'. - Remove currently unimplemented 'solo' marker which may not be needed.
Logging some stuff that I find here Edge case moving sidewaysScreen.Recording.2024-01-24.at.08.42.46.movI expect the element above to the right to get highlighted (it's further away but feels closer). Edge case relation to using mouseI think you'd expect to focus something close to where you clicked last (like in the ) Screen.Recording.2024-01-24.at.08.46.13.mov |
Thanks!
I also noticed some unintuitive jumps in such situations. I have an idea of how to address this, by dividing the actual distance to each candidate by the dot product of its direction with the ideal direction. This dot product is 1 if they point in the same direction, and 0 if they are perpendicular. This should give a penalty to elements which are close but don't lie directly in the axis of movement.
It might not be hard to implement, but maybe we can exclude this from the lib's scope? I assume a no-mouse situation. Nothing should break with a mouse present, but it may not need to be optimized for combined use. |
I was thinking the same.
I already added very basic support. see https://github.com/knuton/focus-shift/pull/1 one more to not loose it: Screen.Recording.2024-01-24.at.10.40.01.mov |
This last one is tricky, I am not sure what should happen. Would you have a specific expectation? I almost feel like it shouldn't move right at all here, but then one would have to watch out to not make navigation to certain elements impossible. Edit: One idea might be to pre-filter candidates by "dominions". For a move to the right, at the moment we consider every element having its left edge to the right of the current element. We could instead consider only those that have their left edge within the rightwards projection of the right wedge of its bounding box. Sketch below. This way we cover the whole space around every element, so one of the four directions should always bring you towards another element. |
good idea, I also played around with the algorithm to get the Screen.Recording.2024-01-24.at.11.49.58.mov |
This penalizes focus candidates which lie in a direction that deviates a lot from the ideal straight direction (e.g. (1, 0) for a move towards the right).
I tried out the dot product idea in 6d4502e, I would say it's a net improvement, but with its own side-effects. Now it jumps to "Normal Button 3" instead of "Normal Button 2". 😄 focus-shift-weighted-distance-2024-01-24_12.18.30.mp4Are you interested in giving the dominion filtering a try? |
Superseded by #2 |
This is a proof of concept implementation with possibly poor performance and also very possibly lots of bugs. Submitted for testing and feedback on the API.
To test, just open
examples/everything-bagel.html
and use the arrow keys.Current status
linear
is not really implemented, just enough to work in the current example.