let up = true;
let down = true;
let screenCounter = 0;
let incrementBy = 1;
let defaultTftMode = "light";
const lengthOfScreen = 4;
// direction would be up or down
function changeScreen(direction = null) {
if (direction === "up") {
if (up == true && screenCounter <= lengthOfScreen) {
if (screenCounter === lengthOfScreen) {
screenCounter = 0;
}else{
screenCounter += incrementBy;
}
} else {
screenCounter = 0;
up = true;
}
}else if(direction === "down"){
if (down == true && screenCounter !== 0) {
screenCounter -= incrementBy;
if (screenCounter === 0) {
down = false;
}
} else {
screenCounter = lengthOfScreen;
down = true;
}
}
console.log('screenCounter value is', screenCounter);
}
Last active
February 15, 2023 09:24
-
-
Save neeraj-tangariya/0a4ff853399e600f7fa7fcbbfbc231b4 to your computer and use it in GitHub Desktop.
slider next and previous button incrementation and decrementation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment