From d6e75d9446a7261f0975dc6bd8dc4404297c1752 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Thu, 1 Sep 2022 12:47:31 +0800 Subject: [PATCH] improve cover display --- include/constants.php | 2 +- public/js/nexus.js | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/include/constants.php b/include/constants.php index 7d47fff0..0f231cca 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ window.innerWidth / 2 && e.pageX + imgWidth > window.innerWidth) { changeOffsetX = true width = e.pageX } - if (e.pageY > window.innerHeight / 2 && e.pageY + imgHeight > window.innerHeight) { - changeOffsetY = true - height = e.pageY + if (e.pageY > window.innerHeight / 2) { + if (e.pageY + imgHeight/2 > window.innerHeight) { + changeOffsetY = 1 + height = e.pageY + } else if (e.pageY + imgHeight > window.innerHeight) { + changeOffsetY = 2 + height = e.pageY + } } let log = `innerWidth: ${window.innerWidth}, innerHeight: ${window.innerHeight}, pageX: ${e.pageX}, pageY: ${e.pageY}, imgWidth: ${imgWidth}, imgHeight: ${imgHeight}, width: ${width}, height: ${height}, offsetX: ${offsetX}, offsetY: ${offsetY}, changeOffsetX: ${changeOffsetX}, changeOffsetY: ${changeOffsetY}` console.log(log) @@ -39,8 +44,10 @@ jQuery(document).ready(function () { if (changeOffsetX) { offsetX = -(e.pageX - width + 10) } - if (changeOffsetY) { - offsetY = -imgHeight/2 + if (changeOffsetY == 1) { + offsetY = - (imgHeight - (window.innerHeight - e.pageY)) + } else if (changeOffsetY == 2) { + offsetY = - imgHeight/2 } return {imgWidth, imgHeight,offsetX, offsetY} }