From 4b48de4f824ce48f1466014a9e9aa24023212181 Mon Sep 17 00:00:00 2001 From: RblSb Date: Fri, 2 May 2025 17:17:00 +0300 Subject: Ignore window.onblur for iframe clicks closes #63 --- res/client.js | 8 ++++++-- src/client/Main.hx | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/res/client.js b/res/client.js index 5c52461..ba579ba 100644 --- a/res/client.js +++ b/res/client.js @@ -1399,7 +1399,11 @@ var client_Main = function() { return _gthis.isPageUnloading = true; }); window.addEventListener("blur",function() { - return _gthis.isPageVisible = false; + var tmp = window.document.activeElement; + if((tmp != null ? tmp.tagName : null) == "IFRAME") { + return; + } + _gthis.isPageVisible = false; }); window.addEventListener("focus",function() { return _gthis.isPageVisible = true; @@ -1744,7 +1748,7 @@ client_Main.prototype = { var data = JSON.parse(e.data); if(this.config != null && this.config.isVerbose) { var t = data.type; - haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 486, className : "client.Main", methodName : "onMessage", customParams : [Reflect.field(data,t.charAt(0).toLowerCase() + HxOverrides.substr(t,1,null))]}); + haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 489, className : "client.Main", methodName : "onMessage", customParams : [Reflect.field(data,t.charAt(0).toLowerCase() + HxOverrides.substr(t,1,null))]}); } client_JsApi.fireEvents(data); switch(data.type) { diff --git a/src/client/Main.hx b/src/client/Main.hx index 9a4c809..d3d1ce2 100644 --- a/src/client/Main.hx +++ b/src/client/Main.hx @@ -117,7 +117,10 @@ class Main { document.addEventListener("click", onFirstInteraction); window.addEventListener("beforeunload", () -> isPageUnloading = true); - window.addEventListener("blur", () -> isPageVisible = false); + window.addEventListener("blur", () -> { + if (document.activeElement?.tagName == "IFRAME") return; + isPageVisible = false; + }); window.addEventListener("focus", () -> isPageVisible = true); document.addEventListener("visibilitychange", () -> { isPageVisible = document.visibilityState == VISIBLE; -- cgit v1.2.3