1

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);
Jamie Hutber
  • 26,790
  • 46
  • 179
  • 291

1 Answers1

2

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() ) ...
Danijel
  • 12,408
  • 5
  • 38
  • 54
  • 3
    you can do that via the getters also. `el.get('tween').isRunning` to match your code since you don't want to save a reference to all possible animation instances. – Dimitar Christoff Aug 22 '13 at 01:47