Skip to content

Commit

Permalink
changed rolover
Browse files Browse the repository at this point in the history
added a functionality for rolling to the start when pressing next at the end
  • Loading branch information
agmes4 committed Jan 27, 2024
1 parent add9e85 commit 6088759
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions web/resources/js/user-suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ waitForKeyPress((event) => {
for (let i= 0; i < navLinks.length; i++){
const link = navLinks[i] as HTMLLinkElement;
if(link.classList.contains("active")) {
let index = (i + 1)%navLinks.length;
const link2 = navLinks[index] as HTMLLinkElement;
let index = (i + 1)% (navLinks.length - 1);
let link2 = navLinks[index] as HTMLLinkElement;
link2.click();
break;
}
}
}

if (event.key === "ArrowLeft" ){
const navLinks = document.getElementsByClassName("user-nav-link");
let next = false;
console.log(navLinks.length)
for (let i= 0; i < navLinks.length; i++){
const link = navLinks[i] as HTMLLinkElement;
if(link.classList.contains("active")) {
let index = (i - 1) % navLinks.length;
let index = i - 1;
if (index < 0) index += (navLinks.length - 1); // Ich hasse JS noch nicht mal mod kann das ordentlich
const link2 = navLinks[index] as HTMLLinkElement;
link2.click();
break;
Expand Down

0 comments on commit 6088759

Please sign in to comment.