Book Image

jQuery for Designers Beginner's Guide Second Edition

By : Natalie Maclees
Book Image

jQuery for Designers Beginner's Guide Second Edition

By: Natalie Maclees

Overview of this book

Table of Contents (21 chapters)
jQuery for Designers Beginner's Guide Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – incorporating custom animations


Next, a sliding animation would be better suited to our menu style. The default animation is to fade the submenus in. We can override this default behavior and replace it with a sliding animation.

  1. Fading the menu in means that the menu opacity is animating from 0 percent to 100 percent. We'd rather animate the height of the submenu, so that the submenu slides into view. To do that, open up your scripts.js file and customize the animation value inside the superfish() method as follows:

      $(document).ready(function(){
        $('#sfNav').superfish({
          animation:  {height:'show'}
        });
      });

    Just adding a value here will override the default behavior of the plugin and replace it with the animation we choose instead.

    Now when you refresh the page in a browser, you'll see the submenus slide into view instead of fade in, which is a much more fitting animation for the CSS We've used to style the menus.

What just happened?

We took advantage of one...