Skip to content

Commit

Permalink
dont allow click on autoroll button if not there
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHeppell committed Jan 31, 2025
1 parent d08a772 commit 0e20036
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chessground",
"version": "7.11.1-pstrat3.11",
"version": "7.11.1-pstrat3.12",
"description": "playstrategy.org chess ui, forked from lichess.org",
"type": "module",
"module": "dist/chessground.js",
Expand Down
2 changes: 2 additions & 0 deletions src/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,9 @@ export function isAutoRollButtonAtDomPos(
pos: cg.NumberPair,
bounds: ClientRect,
variant: cg.Variant = 'chess',
autoRoll: boolean | undefined,
): boolean {
if (autoRoll === undefined) return false;
const correctWidth = (pos[0] - bounds.left) / bounds.width < 8 / 15 && (pos[0] - bounds.left) / bounds.width > 7 / 15;
const correctHeight =
(pos[1] - bounds.top) / bounds.height > 7.65 / 15 && (pos[1] - bounds.top) / bounds.height < 8.4 / 15;
Expand Down
2 changes: 1 addition & 1 deletion src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function startDragOrDraw(s: State): MouchBind {
stopProcessingClick(e);
return;
}
if (isAutoRollButtonAtDomPos(eventPosition(e)!, s.dom.bounds(), s.variant)) {
if (isAutoRollButtonAtDomPos(eventPosition(e)!, s.dom.bounds(), s.variant, s.autoRoll)) {
buttonPressed(s, 'autoroll');
s.autoRoll = !s.autoRoll;
stopProcessingClick(e);
Expand Down

0 comments on commit 0e20036

Please sign in to comment.