Question

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

Solution

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() ) ...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top