title: resolving a promise with EventListener
body: <p>I am working on a popup div and I would like to have a promise attached to the animation so I can do something after the popup ended.</p>
  
  <p>My approach does not work because I could not find a way to pass the promise to the function on the event handler. Seems you cannot use bind here. I have tried and although I can resolve the promise, I cannot remove the event handler</p>
  
  <p>What would be a different solution here?</p>
  
  <pre><code>function EventListenerForPopUp() {
      this.removeEventListener("animationend", EventListenerForPopUp );
      this.Show.resolve();
  }   
  
  function ShowHideDiv() {        
      this.Show = function () { 
          return new Promise(function(resolve, reject) {
              this.Div.addEventListener("animationend", EventListenerForPopUp, false);
          }.bind(this));
      }
  }
  </code></pre>