Skip to content
Advertisement

Handling several .one on same event and element

I have a custom animation framework that uses CSS transitions.

In order to allow for callbacks I attach:

JavaScript

However, some of the same event listeners are fired again and again (yes, it’s actually the same functions with the same guids, I checked). It seems the .one is not properly removing it again.

I’ve tried making a small test-fix with a:

JavaScript

and I get several catches using the boolean to keep track if they have been fired, so I keep them from re-firing at least. But I’d like to know why they are re-firing.

Advertisement

Answer

I doubt that both webkitTransitionEnd and transitionend is beeing fired so you would end up with a lot of unused events bound on your elements. I would unbind the event instead of binding using .one:

JavaScript

Note that the above example doesn’t work when using "use strict". Then you should use:

JavaScript

Not sure if it solves your problem. But you could try.

What is:

arguments.callee
"use strict"

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement