1

I have a problem that I want to first fade the opacity of an image, and only after then move this image to the extreme right of the page. However, Mootools always does these two actions simultaneously instead of sequentially.

 <script type="text/javascript" src="mootools-core-1.3.2-full-compat.js"></script>
 <script type="text/javascript">

 window.addEvents({
     "load" : function() {
         $$('.picture').getLast().setStyle('opacity', 0);                            
         var show = new Fx.Tween($$('.picture').getLast(), { 
             property: 'opacity',
             duration: '2500'
         });

         show.start(1);

         alert($$('.picture').getLast().getStyle('opacity'));

         var movePicture = new Fx.Tween($$('.picture').getLast(), {
             property : 'margin-left',
             duration : '2500'
         });

         while($$('.picture').getLast().getStyle('opacity')!= 1){}

         movePicture.start(700);
     },
     "domready" : function() {
     /* do something */
         function wait(msecs){
             var strt = new Date().getTime();
             var cur = strt
             while(cur - strt < msecs){
                 cur = new Date().getTime();
                 if((cur-strt)%100==0)
                     alert(cur-strt);
             }
         } 
     }
 });

 </script>

I want to execute show.start(1) and then after that is completed, execute movePicture.start(700).

Thanks in advance!

1 Answer 1

2

you need to use the .chain method on Fx.Tween

The official docs have a demo showing how to use it: http://mootools.net/demos/?demo=Chaining

Example: jsFiddle

1
  • Nice to see you around @gonchuki! +1
    – Sergio
    Commented Feb 10, 2014 at 19:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.