Skip to content

Commit

Permalink
webkitvisibilitychange support in monitorer
Browse files Browse the repository at this point in the history
  • Loading branch information
vdvibhu20 committed Apr 10, 2024
1 parent 5781d88 commit 836ae3c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/services/monitorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down

0 comments on commit 836ae3c

Please sign in to comment.