Prevent entering fullscreen if cursor is on control buttons

This commit is contained in:
Keplyx 2018-10-04 14:27:13 +02:00
parent 38d64ea4a1
commit 7df489185d

View file

@ -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()){