为什么on和triggerHandler后面可以加auto_move,move_next
wrap
.on('move_prev',function(){
if(current<=0){
current = size;
}
current = current - 1 ;
wrap.triggerHandler('move_to',current);
})
.on('move_next',function(){
if( current >= size-1){
current = -1;
}
current = current + 1 ;
wrap.triggerHandler('move_to',current);
})
.on('move_to',function(evt,index){
wrap.css('left',index*width*-1);
tips.removeClass('item_focus').eq(index).addClass('item_focus');
})
.on('auto_move',function(){
setInterval(function(){
enableAuto && wrap.triggerHandler('move_next');
},2000);
})
.triggerHandler('auto_move');
// 事件
btn_prev.on('click',function(){
wrap.triggerHandler('move_prev');
});
btn_next.on('click',function(){
wrap.triggerHandler('move_next');
});
tips.on('click',function(){
var index = $(this).index();
wrap.triggerHandler('move_to',index);
})
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星