event.js 316 B

1234567891011
  1. export function waitForEvent(el, eventName) {
  2. return new Promise(resolve => {
  3. function done(event) {
  4. if (event.target === el) {
  5. el.removeEventListener(eventName, done);
  6. resolve();
  7. }
  8. }
  9. el.addEventListener(eventName, done);
  10. });
  11. }