diff --git a/frontend/face-explorer.html b/frontend/face-explorer.html index 506bf37..ab7b544 100644 --- a/frontend/face-explorer.html +++ b/frontend/face-explorer.html @@ -132,27 +132,27 @@ function makeFaceBoxes() { let width, height, offsetLeft = 0, offsetTop = 0; /* If photo is wider than viewport, it will be 100% width and < 100% height */ - if (photo.width / photo.height > el.offsetWidth / el.offsetHeight) { + if (photo.width / photo.height > document.body.offsetWidth / document.body.offsetHeight) { width = 100; - height = 100 * photo.height / photo.width * el.offsetWidth / el.offsetHeight; + height = 100 * photo.height / photo.width * document.body.offsetWidth / document.body.offsetHeight; offsetLeft = 0; offsetTop = (100 - height) * 0.5; } else { - width = 100 * photo.width / photo.height * el.offsetHeight / el.offsetWidth; + width = 100 * photo.width / photo.height * document.body.offsetHeight / document.body.offsetWidth; height = 100; offsetLeft = (100 - width) * 0.5; offsetTop = 0; } - photo.faces.forEach((face) => { const box = document.createElement("div"); box.classList.add("face"); document.body.appendChild(box); - box.style.left = offsetLeft + Math.floor(face.left * width) + "%"; - box.style.top = offsetTop + Math.floor(face.top * height) + "%"; - box.style.width = Math.floor((face.right - face.left) * width) + "%"; - box.style.height = Math.floor((face.bottom - face.top) * height) + "%"; + box.style.left = offsetLeft + face.left * width + "%"; + box.style.top = offsetTop + face.top * height + "%"; + box.style.width = ((face.right - face.left) * width) + "%"; + box.style.height = ((face.bottom - face.top) * height) + "%"; + box.addEventListener("click", (event) => { setPause(true);