Skip to content

Commit

Permalink
Fix mini board moving
Browse files Browse the repository at this point in the history
Signed-off-by: yjf2002ghty <[email protected]>
  • Loading branch information
yjf2002ghty committed Dec 14, 2024
1 parent 8c9170f commit 6e9bb67
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/html/advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -2606,6 +2606,9 @@
chessgroundmini.style.top = `${window.innerHeight - chessgroundminirect.height - padding}px`;
}
} else {
chessgroundmini.style.left = `${chessgroundminirect.left - maindivrect.left}px`;
chessgroundmini.style.top = `${chessgroundminirect.top - maindivrect.top}px`;
chessgroundmini.style.position = "";
if (chessgroundminirect.left < maindivrect.left + padding) {
chessgroundmini.style.left = `${maindivrect.left + padding}px`;
} else if (chessgroundminirect.right > maindivrect.right - padding) {
Expand Down Expand Up @@ -2650,6 +2653,9 @@
chessgroundmini.style.top = `${window.innerHeight - chessgroundminirect.height - padding}px`;
}
} else {
chessgroundmini.style.left = `${chessgroundminirect.left - maindivrect.left}px`;
chessgroundmini.style.top = `${chessgroundminirect.top - maindivrect.top}px`;
chessgroundmini.style.position = "";
if (chessgroundminirect.left < maindivrect.left + padding) {
chessgroundmini.style.left = `${maindivrect.left + padding}px`;
} else if (chessgroundminirect.right > maindivrect.right - padding) {
Expand Down Expand Up @@ -2684,15 +2690,14 @@
) {
return;
}
const maindivrect = maindiv.getBoundingClientRect();
const chessgroundminirect = chessgroundmini.getBoundingClientRect();
if (chessgroundmini.pinned) {
startX = chessgroundminirect.left;
startY = chessgroundminirect.top;
} else {
startX = chessgroundminirect.left - maindivrect.left;
startY = chessgroundminirect.top - maindivrect.top;
if (!chessgroundmini.pinned) {
chessgroundmini.style.left = `${chessgroundminirect.left}px`;
chessgroundmini.style.top = `${chessgroundminirect.top}px`;
chessgroundmini.style.position = "fixed";
}
startX = chessgroundminirect.left;
startY = chessgroundminirect.top;
initialX = event.clientX;
initialY = event.clientY;
document.addEventListener("mousemove", onMouseMove);
Expand All @@ -2705,13 +2710,14 @@
if (event.touches && event.touches.length > 1) {
return;
}
if (chessgroundmini.pinned) {
return;
}
const maindivrect = maindiv.getBoundingClientRect();
const chessgroundminirect = chessgroundmini.getBoundingClientRect();
startX = chessgroundminirect.left - maindivrect.left;
startY = chessgroundminirect.top - maindivrect.top;
if (!chessgroundmini.pinned) {
chessgroundmini.style.left = `${chessgroundminirect.left}px`;
chessgroundmini.style.top = `${chessgroundminirect.top}px`;
chessgroundmini.style.position = "fixed";
}
startX = chessgroundminirect.left;
startY = chessgroundminirect.top;
initialX = event.touches[0].clientX;
initialY = event.touches[0].clientY;
document.addEventListener("touchmove", onTouchMove);
Expand Down

0 comments on commit 6e9bb67

Please sign in to comment.