diff options
author | 0neGal <mail@0negal.com> | 2024-06-19 23:55:30 +0200 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2024-06-19 23:55:30 +0200 |
commit | 3c164a36cb8104853b7272d3de2f85057af28a49 (patch) | |
tree | 277249797bc5fd163eae0d0462663bdb3d7a9e47 /src | |
parent | b89180bdbf8c1fb532a96a2fa235e7bfe45fb46b (diff) | |
download | Viper-3c164a36cb8104853b7272d3de2f85057af28a49.tar.gz Viper-3c164a36cb8104853b7272d3de2f85057af28a49.zip |
select sections when quickly switching to them
This is for when you use Q/E on keyboard or the bumper buttons on a
gamepad, this prevents your selection from being on an element that is
no longer visible.
Diffstat (limited to 'src')
-rw-r--r-- | src/app/js/launcher.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/app/js/launcher.js b/src/app/js/launcher.js index dc99792..546b647 100644 --- a/src/app/js/launcher.js +++ b/src/app/js/launcher.js @@ -203,18 +203,30 @@ launcher.relative_section = (direction) => { } } + let new_section; + // if we're going left, and a previous section was found, click it if (direction == "left" && prev_section) { - prev_section.click(); + new_section = prev_section; } else if (direction == "right") { // click the next section, if one was found, otherwise just // assume that the first section is the next section, as the // active section is likely just the last section, so we wrap // around instead if (next_section) { - next_section.click(); + new_section = next_section; } else if (sections[0]) { - sections[0].click(); + new_section = sections[0]; + } + } + + if (new_section) { + new_section.click(); + + // if there's an active selection, we select the new section, as + // that selection may be in a section that's now hidden + if (document.querySelector(".active-selection")) { + navigate.selection(new_section); } } } |