我有以下代码:我想打电话
(function ($) {
$.fn.waterwheelCarousel = function (options) {
options = $.extend({}, $.fn.waterwheelCarousel.defaults, options || {});
return $(this).each(function () {
var data = {
itemsContainer: $(this).find(".carousel-images"),
totalItems: $(this).find(".carousel-images img").length,
containerWidth: $(this).width(),
containerHeight: $(this).height(),
currentCenterItem: null,
items: [],
itemDistances: [],
waveDistances: [],
itemWidths: [],
itemHeights: [],
itemOpacities: [],
carouselRotationsLeft: 0,
currentlyMoving: false,
itemsAnimating: 0,
currentSpeed: options.speed,
intervalTimer: null
};
// Setup the carousel
beforeLoaded();
// Preload the images. Once they are preloaded, the passed in function
// will be called and the carousel will be setup
preload(function () {
setupDistanceArrays();
setupCarousel();
setupStarterRotation();
});
我试过了:
waterwheelCarousel().preloadfunction()
它给了我未定义的方法
我也尝试过:
var t = $("#waterwheelcarouseldefault").waterwheelCarousel();
t.preloadfunction();
没有运气,任何人都知道如何调用此功能?
答案 0 :(得分:2)
这个函数不是叫做“preload”,而不是“preloadfunction”?
你试过吗
waterwheelCarousel().preload();
答案 1 :(得分:0)
您还可以通过这种方式创建结构对象,使代码更具可读性。例如:
var app =
{
// Setup the carousel
beforeLoaded : beforeLoaded(),
preload: function () {
setupDistanceArrays();
setupCarousel();
setupStarterRotation();
}
};
这样您就可以通过输入app.preload();