I have a problem trying to remove a css transistionend event listener. I am able to add the listener with:
e.addEventListener('transitionend',function(event) {
transitionComplete( event.propertyName );
},false);
I am trying to remove it with
e.removeEventListener('transitionend',function(event) {
transitionComplete( event.propertyName );
},false);
No matter where I put the removeEventListener the listen does not get removed. What can I be doing wrong?
I am not using jquery for this.
I have a problem trying to remove a css transistionend event listener. I am able to add the listener with:
e.addEventListener('transitionend',function(event) {
transitionComplete( event.propertyName );
},false);
I am trying to remove it with
e.removeEventListener('transitionend',function(event) {
transitionComplete( event.propertyName );
},false);
No matter where I put the removeEventListener the listen does not get removed. What can I be doing wrong?
I am not using jquery for this.
Share Improve this question edited Jun 17, 2014 at 20:54 gunr2171 17.6k26 gold badges66 silver badges100 bronze badges asked Jun 17, 2014 at 20:51 Chris HawkinsChris Hawkins 4513 gold badges11 silver badges22 bronze badges1 Answer
Reset to default 9Don't use an anonymous function, instead name the function and put the removal in the event handler.
var func = function(event) {
transitionComplete( event.propertyName );
e.removeEventListener('transitionend',func);
};
e.addEventListener('transitionend',func, false);