You really need to post your entire code. Whatyou show us is not nearly enough to determine what you need to do.
That being said, here's a general idea.
Start with the current gear position in a variable called something like currentGear
When you change to another gear, place the new value into a variable called something like newGear
Then check for what direction it shifted.
If newGear still equals currentGear, do nothing.
if ( currentGear < newGear ) {
// scroll right
}
if ( currentGear > newGear ) {
// scroll left
}
currentGear = newGear;