Ruby-on-Rails
  Home arrow Ruby-on-Rails arrow Page 3 - Introducing script.aculo.us
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
RUBY-ON-RAILS

Introducing script.aculo.us
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2007-11-08

    Table of Contents:
  • Introducing script.aculo.us
  • Visual Effects
  • Toggling
  • Queues

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Introducing script.aculo.us - Toggling


    (Page 3 of 4 )

     

    Some of the effects are grouped into pairs ( Fade/Appear,BlindUp/BlindDown, andSlideUp/SlideDown). script.aculo.us provides a convenient method to toggle between the effects,Effect.toggle:

      Effect.toggle('target') /* uses Fade/Appear */
      Effect.toggle('target', 'blind')
      Effect.toggle('target', 'slide')

    Options

    The Effect.* methods take an optional second parameter: a hash of options. Some options are effect-specific, but we’ll look at those that apply to every effect.

    durationspecifies how long the effect should last, in seconds. For example:

      <%= link_to_function "Fade",
            "new Effect.Fade('target', { duration:5 })" %>

    fpsdetermines the frames per second. The default is 25, and it can’t exceed 100. For example:

      <%= link_to_function "Choppy Fade",
            "new Effect.Fade('target', { duration:10, fps:2 })" %>

    Note that because script.aculo.us effects are time-based, rather than frame-based, slower systems will automatically drop frames as necessary.

    delayspecifies the time in seconds before the effect will be started. For example:

      <%= link_to_function "Fade",
            "new Effect.Fade('target', { delay:2 })" %>

    fromandtodefine the starting and ending points of the effect as values between0and1. For example, you could jump directly to the halfway point of an effect, then gradually fade to 25 percent, and then stop:

      <%= link_to_function "Fade with from",
            "new Effect.Fade('target', { from:0.5, to:0.25 })" %>

    More Ruby-on-Rails Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Ajax on Rails," published by O'Reilly. We...
     

    Buy this book now. This article is excerpted from chapter four of the book Ajax on Rails, written by Scott Raymond (O'Reilly, 2007; ISBN: 0596527446). Check it out today at your favorite bookstore. Buy this book now.

    RUBY-ON-RAILS ARTICLES

    - Calculating Statistics with Active Record
    - Creating Graphs with Ruby
    - Callbacks and the Active Record
    - Validation and the Active Record
    - Arrays, Associations and the Active Record
    - Associations and Dependencies with Active Re...
    - Advanced Active Record: Enhancing Your Models
    - Load Balancing Databases with Rails
    - More Advanced Database Features and Rails
    - Handling Advanced Database Features with Rai...
    - Managing Database Files with Ruby on Rails
    - Databases and Ruby on Rails
    - Updating and Deleting with the Active Record
    - Rails Active Record and CRUD Functions
    - Working with a Database: Active Record







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 11 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek