Hi,
I'm trying to change this if statement to a switch like this:
Before
Code:
if ($(this).attr('id') === 'right') {
if (tabindex === slides) {
tabindex = 1;
move = '+=' + windowWidth * (slides - 1);
} else {
tabindex += 1;
move = '-=' + windowWidth;
}
} else {
if (tabindex === 1) {
tabindex = slides;
move = '-=' + windowWidth * (slides - 1);
} else {
tabindex -= 1;
move = '+=' + windowWidth;
}
}
After
Code:
if ($(this).attr('id') === 'right') {
switch (tabindex) {
case (tabindex === slides):
tabindex = 1;
move = '+=' + windowWidth * (slides - 1);
break;
default:
tabindex += 1;
move = '-=' + windowWidth;
}
} else {
switch (tabindex) {
case (tabindex === 1):
tabindex = slides;
move = '-=' + windowWidth * (slides - 1);
break;
default:
tabindex -= 1;
move = '+=' + windowWidth;
}
But the result is not the same.
What am I doing wrong? What is the right solution?
Thanks
Bookmarks