MooTools – Fx.Options


MooTools – Fx.Options


”;


MooTools provides different Fx.Options which will help to Fx.Tween and Fx.Morph. These options will give you a control over the effects.

Let us discuss a few options that MooTools provide. Before we proceed, take a look at the following syntax for setting up options.

Syntax

var morphObject = new Fx.Morph(morphElement, {
   //first state the name of the option
   //place a :
   //then define your option
});

fps(frames per second)

This option determines the number of frames per second in the animation while morphing. We can apply these fps to Morph or Tween functionalities. By default, the value of fps is 50. This means any functionality will take 50 frames per second while morphing.

Example

Let us take an example wherein, we will morph a div element using 5 fps. Take a look at the following code.

<!DOCTYPE html>
<html&gt

   <head>
      <style>
         #morph_element {
            width: 100px;
            height: 100px;
            background-color: #1A5276;
            border: 3px solid #dd97a1;
         }
      </style>
      
      <script type = "text/javascript" src = "MooTools-Core-1.6.0.js"></script>
      <script type = "text/javascript" src = "MooTools-More-1.6.0.js"></script>
      
      <script type = "text/javascript">
         var morphStart = function(){
            this.start({
               ''width'': 200,
               ''height'': 200,
               ''background-color'': ''#d3715c''
            });
         }
         
         window.addEvent(''domready'', function() {
            var morphElement = $(''morph_element'');
            var morphObject = new Fx.Morph(morphElement, {
               fps: 5
            });
            
            $(''start'').addEvent(''click'', morphStart.bind(morphObject));
         });
      </script>
   </head>
   
   <body>
      <div id = "morph_element"> </div><br/>
      <input type = "button" id = "start"value = "START"/>
   </body>
   
</html>

You will receive the following output −

Output