From 7df489185ddcdf01d7a15e06d0aa72876747e0b6 Mon Sep 17 00:00:00 2001 From: Keplyx Date: Thu, 4 Oct 2018 14:27:13 +0200 Subject: [PATCH] Prevent entering fullscreen if cursor is on control buttons --- assets/scripts/photosScript.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/assets/scripts/photosScript.js b/assets/scripts/photosScript.js index c11a030..2dfc7b3 100755 --- a/assets/scripts/photosScript.js +++ b/assets/scripts/photosScript.js @@ -13,6 +13,7 @@ var grab_offsetY = 0; var idle_time = 0; var scaling = false; var isMobile = window.matchMedia("only screen and (max-width: 480px)").matches; +var isMouseOverButtons = false; $(document).ready( function () { @@ -63,7 +64,10 @@ $(document).ready( } ); -$(document).mousemove(function () { +$(document).mousemove(function (event) { + let cursorY = event.pageY - $(window).scrollTop(); + var elem = document.elementFromPoint(event.pageX, cursorY); + isMouseOverButtons = !(elem.id === "close-back" || elem.id === "img-big"); // Prevent entering fullscreen when cursor on control buttons idle_time = 0; }); @@ -162,7 +166,10 @@ function is_fullscreen(){ function timerIncrement() { - idle_time = idle_time+ 1; + if (isMouseOverButtons) + idle_time = 0; + else + idle_time = idle_time+ 1; if (idle_time > 10 && !is_fullscreen()) { // 1 second enableFullscreen(); } else if (idle_time <= 10 && is_fullscreen()){