You do not need to pass the promise to the event handler, you need to pass the resolve
callback:
function EventListenerForPopUp(resolve) {
this.removeEventListener("animationend", EventListenerForPopUp );
resolve();
}
// [...]
return new Promise(function(resolve, reject) {
this.Div.addEventListener("animationend", function() {
EventListenerForPopUp.call(this, resolve);
}, false);
This looks a bit ugly to me, maybe you can look at something like this:
var div = this.Div;
return new Promise(function (resolve) {
div.addEventListener("animationend", function animationendListener() {
div.removeEventListener("animationend", animationendListener);
//call any handler you want here, if needed
resolve();
});
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…