私はjqueryプラグインが初めてです。必要に応じて scrollWidth を変更できるように、totalWidth をオプションとして指定する必要があります。誰かが私を助けることができますか?
(function( $ ) {
$.fn.scrollAnimation = function(options) {
var totalWidth;
var settings = $.extend( {
'totalWidth' :'totalWidth'
}, options);
return this.each(function() {
var element = $(this);
var offset_1 = $("ul li.list:first-child",element).position().left;
var offset_2 = $("ul li.list:nth-child(2)",element).position().left;
var totalWidth =(offset_2-offset_1);
$(".abc",element).click(function() {
$(".images",element).not(":animated").animate({"scrollLeft":"-="+totalWidth},300);
return false;
});
$(".def",element).click(function() {
$(".images",element).not(":animated").animate({"scrollLeft":"+="+totalWidth},300);
return false;
});
});
};
})( jQuery );