Hey
I put this example together. It's not a scriptaculous effect but an
important thing to remember is that prototype and scriptaculous provide the
building blocks to construct pretty much anything.
It is by no means the most concise example, but should get you started and
give you plenty to research.
function reveal(sentence, delayPerLetter) {
var data = sentence.toArray();
var container = new Element('div');
$$('body').first().insert(container);
var delayAmount = 0;
data.each(function(letter) {
delayAmount += delayPerLetter;
if (letter == ' ') letter = ' ';
span = new Element('span').hide().update(letter);
(function() {
new Effect.Appear(this);
}).bind(span).delay(delayAmount);
container.insert(span);
});
return container;
}
function unreveal(container, delayperletter)
{
var data = container.select('span').reverse();
var delayamount = 0;
data.each(function(letterspan) {
delayamount += delayperletter;
(function() {
new Effect.Fade(this, { afterFinish: function(effect) {
effect.element.remove(); } });
}).bind(letterspan).delay(delayamount);
});
(function() { container.remove(); }).delay(delayamount + 1);
}
Event.observe(window, 'load', function(e) {
var sentence = 'Hello this is a sentence';
var delayPerLetter = 0.05;
var revealEffect = reveal(sentence, delayPerLetter);
(function() {
unreveal(revealEffect, delayPerLetter);
}).delay(2);
});
On Thu, Aug 20, 2009 at 6:41 PM, Mojito <[email protected]> wrote:
>
> Is there a Scriptaculous effect to spell out a word slowy:
>
> S
> SE
> SEN
> SENT
> SENTE
> SENTEN
> SENTENCE
>
> And also delete it slowly?
>
> SENTENCE
> SENTENC
> SENTEN
> SENTE
> SENT
> SEN
> SE
> S
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---