How do I find out with Mootools if an element is being animated?

134 views Asked by At

I need to be able to detect is an animation is currently happening using Mootools.

Of course if there is a way to detect this with plain old js even better. But I couldn't think of a way to do this without running it every ms and seeing if the styles are changing.

How i'm doing the animation

                new Fx.Tween(c.getElement('.is-active'), {
                    property: 'opacity',
                    duration: e.options.speed,
                    onComplete: function () {
                        this.element
                            .removeClass("is-active")
                            .addClass("is-hidden")
                            .setStyle('display', "")
                            .setStyle('opacity', "");
                    }
                }).start(0).wait(e.options.speed);
1

There are 1 answers

1
Danijel On BEST ANSWER

One way that I often use is to check if animation is running with isRunning function:

// constructor
var fx = new Fx.Tween( .... 

// later when I want to check if animation is running
if ( fx.isRunning() ) ...