diff --git a/src/UserActivity.js b/src/UserActivity.js index 145b23e36e..b49bcf1a91 100644 --- a/src/UserActivity.js +++ b/src/UserActivity.js @@ -1,5 +1,6 @@ /* Copyright 2015, 2016 OpenMarket Ltd +Copyright 2019 New Vector Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -33,7 +34,7 @@ class UserActivity { this._attachedTimers = []; this._activityTimeout = new Timer(CURRENTLY_ACTIVE_THRESHOLD_MS); this._onUserActivity = this._onUserActivity.bind(this); - this._onDocumentBlurred = this._onDocumentBlurred.bind(this); + this._onWindowBlurred = this._onWindowBlurred.bind(this); this._onPageVisibilityChanged = this._onPageVisibilityChanged.bind(this); this.lastScreenX = 0; this.lastScreenY = 0; @@ -74,8 +75,8 @@ class UserActivity { document.onmousemove = this._onUserActivity; document.onkeydown = this._onUserActivity; document.addEventListener("visibilitychange", this._onPageVisibilityChanged); - document.addEventListener("blur", this._onDocumentBlurred); - document.addEventListener("focus", this._onUserActivity); + window.addEventListener("blur", this._onWindowBlurred); + window.addEventListener("focus", this._onUserActivity); // can't use document.scroll here because that's only the document // itself being scrolled. Need to use addEventListener's useCapture. // also this needs to be the wheel event, not scroll, as scroll is @@ -116,7 +117,7 @@ class UserActivity { } } - _onDocumentBlurred() { + _onWindowBlurred() { this._activityTimeout.abort(); }