Book Image

MooTools 1.2 Beginner's Guide

Book Image

MooTools 1.2 Beginner's Guide

Overview of this book

MooTools is a simple-to-use JavaScript library, ideal for people with basic JavaScript skills who want to elevate their web applications to a superior level. If you're a newcomer to MooTools looking to build dynamic, rich, and user-interactive web site applications this beginner's guide with its easy-to-follow step-by-step instructions is all you need to rapidly get to grips with MooTools.
Table of Contents (14 chapters)
MooTools 1.2 Beginner's Guide
Credits
About the Authors
About the Reviewer
Preface

Time for action— experimenting with morph


To explore the morph method, we will use a div with text inside it to morph several of its properties.

  1. We will use an element to trigger the animation effect. We will run the animation on a div element with an ID of morphDiv.

    <a href="#null">Morph</a>
    <div id="morphDiv">
    <p>My Morphing Box.</p>
    </div>
    
  2. We will give morphDiv some CSS styles to modify its default styles.

    #morphDiv {
    width:100px;
    height:100px;
    border:1px solid #333;
    background:#ccc;
    font:normal 12px Arial, Helvetica, sans-serif;
    }
    
  3. We add a click event listener to the<a> element so that when it's clicked, it executes the morph method on morphDiv. We transition several properties.

    $$('a').addEvent('click', function(){
    $('morphDiv').morph({
    'width' : 200,
    'height' : 200,
    'border' : '5px dashed #ff0000',
    'font-size' : '24px'
    });
    });
    
  4. When you click on the<a> element, it should transition all of the CSS properties of morphDiv to the values we've...