jQuery 용 플러그인을 만들고 있는데 애니메이션이 끝난 후에 같은 함수를 다시 실행해야합니다. 애니메이션 기능을 setTimeout()
사용하여이 작업을 위해 노력하고있어.애니메이션 내에서 jQuery 부모 함수 실행
jQuery(theslide).animate(theanimation,1000,function() {
setTimeout('this.makemeslide()',3000)
})
입니다 내가 함께 사투를 벌인거야 코드는 하단에
입니다 : 개체 [개체 창] 때문에 본하게있는 방법 'makemeslide'이 없습니다 이것은 움직이는 물체의 지점입니다. 그러나 나는 나의 목표를 달성하는 방법을 모른다. 코드 문자열 여기
내 전체 코드
jQuery.fn.daSlider = function(options) {
//Options
var settings = $.extend({
'selector' : 'slider',
'width' : 940,
'height' : 380
}, options);
//globals
var sliderarray = [];
var slidercount = 0;
//Contruct
this.construct = function()
{
jQuery('.slider .slide').each(function(){
jQuery(this).css('display','none');
sliderarray.push(this) ;
jQuery(this).children().each(function(){
jQuery(this).css('display','none');
sliderarray.push(this) ;
});
});
this.makemeslide();
}
//run the constuct
this.makemeslide = function()
{
theslide = sliderarray[slidercount];
slidercount++;
way_to_slide = jQuery(theslide).attr('slide');
slide_position = jQuery(theslide).position();
//console.log(slide_width);
//console.log(slide_height);
if(way_to_slide == 'right')
{
jQuery(theslide).css('left', slide_position.left + settings.width);
theanimation = {'left' : '-='+settings.width};
}
if(way_to_slide == 'left')
{
jQuery(theslide).css('left', slide_position.left - settings.width);
theanimation = {'left' : '+='+settings.width};
}
if(way_to_slide == 'up')
{
jQuery(theslide).css('top', slide_position.top - settings.height);
theanimation = {'top' : '+='+settings.height};
}
if(way_to_slide == 'down')
{
jQuery(theslide).css('top', slide_position.top + settings.height);
theanimation = {'top' : '-='+settings.height};
}
if(way_to_slide == 'fade')
{
jQuery(theslide).css('opacity', 0);
theanimation = {'opacity' : 1};
}
jQuery(theslide).css('display','block') ;
jQuery(theslide).animate(theanimation,1000,function(){setTimeout('this.makemeslide()',3000)})
}
this.construct();
};
'this'이 될 두 번째 경고가 당신에게 윈도우 객체가 아닌 오 - 객체를 보여줄 것
주 ? 이 'makemeslide' 및'construct' 속성을 할당하는 것은 jQuery 래퍼 객체입니다. – Bergi
도움을 주신 모든 분들께 감사드립니다. –