Hello,
I've got a small piece of code for a slider working correctly with
mootools 1.1. but not with 1.2
Would be great if someone could help me out.
/**********************************************/
The mootools 1.1. code
/************************************************/
window.addEvent('domready', function(){
          var totIncrement              = 0;
          var increment                 = 942;
          var maxRightIncrement = increment*(-1);
          var fx = new Fx.Style('myList', 'margin-left', {
                                duration: 1500,
                                transition: Fx.Transitions.Back.easeInOut,
                                wait: true
           });

           //-------------------------------------
          // EVENTS for the button "previous"
          $('previous').addEvents({
          'click' : function(event){
                  if(totIncrement<0){
                                        totIncrement = totIncrement+increment;
                                        fx.stop()
                                        fx.start(totIncrement);
                                }
                        }
      });

       //-------------------------------------
          // EVENTS for the button "next"
          $('next').addEvents({
          'click' : function(event){
                         if(totIncrement>maxRightIncrement){
                                 totIncrement = totIncrement-increment;
                        fx.stop()
                                fx.start(totIncrement);
                        }
          }
      })


});

/********************************************/
The mootools 1.2. code
/*******************************************/
window.addEvent('domready', function(){
var totIncrement = 0;
var increment = 387;
var totalIncrements = $$("#sMylist li").length - 1
var maxRightIncrement = increment*(- totalIncrements);

var fx = new Fx.Tween('sliderList', {
   property: 'margin-left',
   duration: 1000,
   transition: Fx.Transitions.Back.easeInOut,
   onStart: function() {
      $("previous").removeEvents('click');
      $("next").removeEvents('click');
   },
   onComplete: function() {
      appEvent();
   }
});

function appEvent() {
   // Previous Button
   $('previous).addEvents({
      'click' : function(event){
         if(totIncrement&lt;0){
            event.stop();
            totIncrement = totIncrement + increment;
            fx.start(totIncrement);
        }
      }
   });

   // Next Button
   $('next').addEvents({
      'click' : function(event){
         if(totIncrement&gt;maxRightIncrement){
            event.stop();
            totIncrement = totIncrement - increment;
            fx.start(totIncrement);
        }
      }
   });
}
appEvent();
 });

Reply via email to