mootools fx.reveal

872 views Asked by At

I'm trying to do a simple show/hide transition for a message div using fx.reveal in mootools 1.4. The effect works the first time, but not on subsequent clicks.

Any hints as to where I'm going wrong?

http://jsfiddle.net/MYgH6/1/

var mytween = new Fx.Reveal(document.getElementById('mydiv'), {duration: 2500});

$('myclick').addEvent('click', function(){
    mymessage();
});

function mymessage(){
    var mymessage = document.getElementById('mydiv');

    mymessage.set('html','YO!');

    mytween.reveal();
    mytween.dissolve();
}
2

There are 2 answers

1
AHHP On BEST ANSWER
var mytween = new Fx.Reveal(document.getElementById('mydiv'), {
    duration: 1000,
    onComplete:function(){
        this.element.dissolve();
    }
});

$('myclick').addEvent('click', function(){
    mymessage();
});

function mymessage(){
    var mymessage = document.getElementById('mydiv');

    mymessage.set('html','YO!');

    mytween.reveal();
}
0
zalun On

I know it's not best answer, as you specified using Fx.Reveal, but I'd use wink command http://mootools.net/docs/more/Fx/Fx.Reveal#Element:wink

Like here: http://jsfiddle.net/zalun/MYgH6/5/

var msg = document.getElementById('mydiv').hide();
$('myclick').addEvent('click', function() {
    msg.wink();
});

You can certainly specify the message within the function as you did before.