Home arrow Ruby-on-Rails arrow Page 3 - Introducing script.aculo.us
RUBY-ON-RAILS

Introducing script.aculo.us


Rails can be used with more than Ruby. In this three-part series, you'll find out about the visual effects you can do with script.aculo.us on Rails. It is excerpted from chapter four of the book Ajax on Rails, written by Scott Raymond (O'Reilly, 2007; ISBN: 0596527446).

Author Info:
By: O'Reilly Media
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
November 08, 2007
TABLE OF CONTENTS:
  1. · Introducing script.aculo.us
  2. · Visual Effects
  3. · Toggling
  4. · Queues

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

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 })" %>

Next: Queues >>

blog comments powered by Disqus
RUBY-ON-RAILS ARTICLES

- Adding Style with Action Pack
- Handling HTML in Templates with Action Pack
- Filters, Controllers and Helpers in Action P...
- Action Pack and Controller Filters
- Action Pack Categories and Events
- Logging Out, Events and Templates with Actio...
- Action Pack Sessions and Architecture
- More on Action Pack Partial Templates
- Action Pack Partial Templates
- Displaying Error Messages with the Action Pa...
- Action Pack Request Parameters
- Creating an Action Pack Registration Form
- Ruby on Rails Templates and Layouts
- Action Pack Controller Creation
- Writing an Action Pack Controller

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 6 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials