From 836ae3c929564537c9e8dd99caebd21287ae2384 Mon Sep 17 00:00:00 2001 From: Vibhu Dujari Date: Wed, 10 Apr 2024 14:46:49 +0530 Subject: [PATCH] webkitvisibilitychange support in monitorer --- app/services/monitorer.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/services/monitorer.js b/app/services/monitorer.js index f022640..9ea36b8 100644 --- a/app/services/monitorer.js +++ b/app/services/monitorer.js @@ -88,8 +88,12 @@ export default Service.extend({ async setTabSwitchEvents() {//called based on route activation const currentAttempt = await this.router.get('currentRoute.attributes.contest.currentAttempt') if(!!!currentAttempt.id) return - console.log('visibility change event listener added') - document.addEventListener("visibilitychange", this.tabSwitchEventHandler); + + if('webkitHidden' in document) { + document.addEventListener("webkitvisibilitychange", this.tabSwitchEventHandler); + } else { + document.addEventListener("visibilitychange", this.tabSwitchEventHandler); + } }, async setWindowResizeEvents() {//called based on route activation @@ -107,7 +111,6 @@ export default Service.extend({ }, async tabSwitchEventHandler() { - console.log('visibility changed', 'document.hidden', document.hidden) if(!document.hidden) return this.set('tabSwitchTrigger', true) const currentAttempt = await this.router.get('currentRoute.attributes.contest.currentAttempt')