Only start NoSleep after the first user interaction

This commit is contained in:
Lucas Verney 2018-06-28 15:08:56 +02:00
parent a4564ad053
commit 4493dc35fe
2 changed files with 21 additions and 3 deletions

View File

@ -47,7 +47,7 @@ export default {
},
created() {
this.initializePositionWatching();
this.setNoSleep();
this.listenForFirstInteraction();
this.$store.dispatch('fetchReports');
window.addEventListener('keydown', this.hideReportDialogOnEsc);
},
@ -162,6 +162,26 @@ export default {
this.dialog = false;
}
},
handleFirstUserInteraction() {
this.setNoSleep();
window.removeEventListener('mousemove', this.handleFirstUserInteraction, false);
window.removeEventListener('mousedown', this.handleFirstUserInteraction, false);
window.removeEventListener('keypress', this.handleFirstUserInteraction, false);
window.removeEventListener('DOMMouseScroll', this.handleFirstUserInteraction, false);
window.removeEventListener('mousewheel', this.handleFirstUserInteraction, false);
window.removeEventListener('touchmove', this.handleFirstUserInteraction, false);
window.removeEventListener('MSPointerMove', this.handleFirstUserInteraction, false);
},
listenForFirstInteraction() {
window.addEventListener('mousemove', this.handleFirstUserInteraction, false);
window.addEventListener('mousedown', this.handleFirstUserInteraction, false);
window.addEventListener('keypress', this.handleFirstUserInteraction, false);
window.addEventListener('DOMMouseScroll', this.handleFirstUserInteraction, false);
window.addEventListener('mousewheel', this.handleFirstUserInteraction, false);
window.addEventListener('touchmove', this.handleFirstUserInteraction, false);
window.addEventListener('MSPointerMove', this.handleFirstUserInteraction, false);
},
},
};
</script>

View File

@ -19,8 +19,6 @@
</template>
<script>
import Vue from 'vue';
import { messages } from '@/i18n';
import { storageAvailable } from '@/tools';