open-nomad/ui/app/mixins/with-component-visibility-d...

13 lines
444 B
JavaScript

import Mixin from '@ember/object/mixin';
export default Mixin.create({
setupDocumentVisibility: function() {
this.set('_visibilityHandler', this.get('visibilityHandler').bind(this));
document.addEventListener('visibilitychange', this.get('_visibilityHandler'));
}.on('init'),
removeDocumentVisibility: function() {
document.removeEventListener('visibilitychange', this.get('_visibilityHandler'));
}.on('willDestroy'),
});