I'm building a plugin with the code below. If I change $(opts.section, this).animate to $(opts.section).animate it works as I want it too, but it animates all instances of the section element, and I want it to only affect this current one. Once I add "this" to it, it stops working all together.
$('.next', this).on({
click: function() {
if(count+2 <= totalElems) {
count += 1;
currentAnimationSpot += singleElem + opts.offset;
$(opts.section, this).animate({
left: -currentAnimationSpot
});
}
}
});
$('.prev', this).on({
click: function(){
if(count != 1) {
count-=1;
currentAnimationSpot -= singleElem + opts.offset;
$(opts.section, this).animate({
left: -currentAnimationSpot
});
}
}
});