1

私は次のようなものを持っています:

$('#test').bind('go', function(event, top, left,w,h) {
  $('#test').animate({left: left, top : top, width: w,height: h},1000,function() {
     $('#test').animate({left: 0, top :0, width: w,height: h},1000)  ;      
  })
});

$('#test').trigger('go', [150, 200,100,80]);
$('#test').trigger('go', [250, 200,100,80]);
$('#test').trigger('go', [350, 200,100,80]);

ただし、2番目と3番目のトリガーは、最初のトリガーが終了する前に開始されます。前が完了したときに次のmain.triggerを開始したい。

試してみてください:http://jsfiddle.net/9NLrR/6/

ありがとう

4

2 に答える 2

0

可変値を維持して遊ぶことができます

var trigger=0;

main.bind('go', function(event, top, left,w,h,triggervalue) {

   if(triggervalue==trigger)
   { 
    bidule.animate({left: left, top : top, width: w,height: h},1000);
    trigger++;
   }

}

main.trigger('go', [150, 200,100,80,1]);
main.trigger('go', [250, 200,100,80,2]);
main.trigger('go', [350, 200,100,80,3]);
于 2012-08-24T09:17:28.150 に答える
0

これをテストします:

<div style="height:100px; width:100px; background-color:red; position:absolute;" id="test"></div>​

およびスクリプト:

<script type="text/javascript">
    $('#test').bind('go', function(event, top, left,w,h) {
        $('#test').animate({left: left, top : top, width: w,height: h},1000);  
        $('#test').animate({left: 0, top : 0, width: w,height: h},1000);     
    });

    $('#test').trigger('go', [150, 200,100,80]);
    $('#test').trigger('go', [250, 200,100,80]);
    $('#test').trigger('go', [350, 200,100,80]);
</script>
于 2012-08-24T09:34:47.333 に答える