jeudi 14 décembre 2017

Ember Window Event Listener not working

I added a window event listener in the route because I want to detect when a user is in another tab or not - focus vs blur state. So I used the init method to do this but .. its not being triggered at all or not working.

  init() {
   this._super(...arguments);
   window.addEventListener('blur,focus', e => {
     switch (e.key) {
       case "blur":
         this.get('player').pauseVideo();
         break;
       case "focus":
         this.get('player').playVideo();
         break;
     }
   });
  }

any ideas to what im doing wrong here to make this work in ember




Aucun commentaire:

Enregistrer un commentaire