最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Removing CSS transitionend event listener not working - Stack Overflow

programmeradmin0浏览0评论

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 badges
Add a ment  | 

1 Answer 1

Reset to default 9

Don'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);
发布评论

评论列表(0)

  1. 暂无评论