Basically, the reverse of abs. If I have:
if ($this.find('.pdxslide-activeSlide').index() < slideNum - 1) {
slideNum = -slideNum
}
console.log(slideNum)
No matter what console always returns a positive number. How do I fix this?
If I do:
if ($this.find('.pdxslide-activeSlide').index() < slideNum - 1) {
_selector.animate({
left: (-slideNum * sizes.images.width) + 'px'
}, 750, 'InOutPDX')
} else {
_selector.animate({
left: (slideNum * sizes.images.width) + 'px'
}, 750, 'InOutPDX')
}
it works tho, but it's not "DRY" and just stupid to have an entire block of code JUST for a -
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…