Prototype & Scriptaculous are awesome!

handgestrickt is programming a user interface recently, where a window with a drop shadow should appear in the middle and the rest of the page should fade out a little bit.

sounds complicated? no way! with Prototype.js and Scriptaculous it is easy.

first the fading out. Scriptaculous has some nice function called Effect.Opacity() which does the trick. Prototype.js provides a function called Position.clone() which clones the exact position of another element. the best is, you can provide an offset. the example:

new Effect.Opacity('overlay', {
        from: 0.0,
        to: 0.6,
        beforeStart: function() {
                $('overlay').style.display = 'block';
        },
        afterFinish: function() {
     $('content').style.display = 'block';
                Position.clone($('content'),$('shadow'),{
                        offsetLeft: 10,
                        offsetTop: 10
                });
                $('shadow').style.display = 'block';
        }
});

awesome!

Monday, 05. March 2007 • trackback url

Add Comment

( to reply to a comment, click the reply link next to the comment )

Comment Title:
Your Name:
Email Address:
Make Public?
Website:
Make Public?

Comment:


Allowed XHTML tags : a, b, i, strong, code, acrynom, blockquote, abbr. Linebreaks will be converted automatically.


Captcha:

captcha image

please type the content of the above image into the following form-field: