Situation : I have an event listener on an item. When I press on it, it calls a method that will perform a webkitAnimation and I return the end of the animation as a result.
Problem : If I click several times on my item, the webkit animation's listener is not reset, so I get many callbacks ..
I tried to use removeEventListener but it doesn't work..
Thanks in advance!
var Test = (function () {
function Test(listItem) {
this.listItem = listItem;
listItem.addEventListener('click', function(event) {
this.startAnim(function() {
});
}
}
Test.prototype.startAnim = function(callback) {
this.listItem.style.webkitAnimationName = 'simpleAnim';
this.listItem.style.webkitAnimationDuration = '220ms';
this.listItem.addEventListener('webkitAnimationEnd', function() {
this.style.webkitAnimationName = '';
// This calls my callback too many times..
callback();
// the following doesn't work!
this.removeEventListener('webkitAnimationEnd', function() {
// this doesn't work....
}, false);
}, false);
};
return Test;
}