Basically, the reverse of abs. If I have:
if ($this.find(\'.pdxslide-activeSlide\').index() < slideNum - 1) {
slideNum = -slideNum
}
console.log(slideNu
Are you sure that control is going into the body of the if
? As in does the condition in the if
ever hold true? Because if it doesn't, the body of the if
will never get executed and slideNum
will remain positive. I'm going to hazard a guess that this is probably what you're seeing.
If I try the following in Firebug, it seems to work:
>>> i = 5; console.log(i); i = -i; console.log(i);
5
-5
slideNum *= -1
should also work. As should Math.abs(slideNum) * -1
.