以下のコードでプラグインを作成しています。$(opts.section, this).animate を $(opts.section).animate に変更すると、希望どおりに動作しますが、セクション要素のすべてのインスタンスをアニメーション化するため、現在のインスタンスのみに影響を与えたい. 「これ」を追加すると、すべて一緒に機能しなくなります。
$('.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
});
}
}
});