0
저는 jquery에 처음 접했고 첫 번째 플러그인을 만들었지 만 문제가 발생했습니다. 제대로 작동하도록 할 수는 있지만 옵션에 제 기능을 추가하면 올바르게 읽지 않는 것 같습니다. 예를 들어, slideshowTransition 옵션이 있지만 내 rotateImages 함수에서 읽지 않는 것 같습니다. 콘솔로 출력 할 수는 있지만 읽을 수없는 이유는 모르겠습니다. 아래 코드를 참조하십시오 :jquery 플러그인 옵션이 읽히지 않습니다.
(function($){
$.fn.imageRotator = function(config, slideshowSpeed) {
$.imageRotator = {
defaults: {
slideshowSpeed: '3000',
slideshowTransition: '4000'
}
};
settings = $.extend({}, $.imageRotator.defaults, config);
//loop back to the top once rotateimages function is complete
setInterval(rotateImages, settings.slideshowSpeed);
function rotateImages(config){
var currentPhoto = $("#photo_slideshow .current");
var nextPhoto = currentPhoto.next();
//used to loop back to the top once the last image is finished
if(nextPhoto.length == 0){
nextPhoto = $("#photo_slideshow div:first");
}
currentPhoto.removeClass('current').addClass('previous');
console.log(settings.slideshowSpeed);
//take what's next make it visible and move it on top
nextPhoto.css({ opacity: 0 }).addClass('current').animate({ opacity: 1.0 }, settings.slideshowTransition,
//callback function to drop photo down to the bottom of the z-index
function(){
currentPhoto.removeClass('previous');
}
)
};
//end rotate images function
};
})(jQuery);
어떤 도움을 주시면 감사하겠습니다! 감사! 귀하의 질문에 대한 나의 이해에 따르면
@Ravi에 답해 주셔서 감사하지만이 코드 줄에 옵션을 추가하면 ** nextPhoto.css ({opacity : 0}). addClass ('current'). animate ({opacity : 1.0}, settings). slideshowTransition, ** "settings.slideshowTransition"옵션이 읽히지 않습니다. 이유가 무엇입니까? –
안녕 델몬, 나는 왜 당신이 settings.slideshowTransition의 가치를 얻지 못하고 있는지 모르겠다. 코드와 관련 html을 게시 할 수 있습니까? jsfiddle 함수 호출 거즈는 모양을 가지고 무엇을 도와 줄 수 있습니까? –
안녕하세요 @ravi. 죄송합니다 지금까지 게시 할 수 없었습니다. 여기 jsfiddle : http://jsfiddle.net에 내 코드가 있습니다./ghowell/d5P9n /. ** settings.slideshowTransition ** 값을 콘솔에 인쇄 할 수 있지만 nextPhoto.css로 시작하는 코드의 마지막 줄은 읽을 수 없습니다. –