English 中文(简体)
MooTools - Fx.Options
  • 时间:2024-09-17

MooTools - Fx.Options


Previous Page Next Page  

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 functionapties. By default, the value of fps is 50. This means any functionapty will take 50 frames per second while morphing.

Example

Let us take an example wherein, we will morph a span 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 sopd #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( cpck , morphStart.bind(morphObject));
         });
      </script>
   </head>
   
   <body>
      <span id = "morph_element"> </span><br/>
      <input type = "button" id = "start"value = "START"/>
   </body>
   
</html>

You will receive the following output −

Output