Question

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();
}
Was it helpful?

Solution

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();
}

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top