From 0e200363458ab7029d3519113d82fa67f285dd2a Mon Sep 17 00:00:00 2001 From: JamesHeppell Date: Fri, 31 Jan 2025 16:05:56 +0000 Subject: [PATCH] dont allow click on autoroll button if not there --- package.json | 2 +- src/board.ts | 2 ++ src/events.ts | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7ee0db6..da1c5a9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/board.ts b/src/board.ts index 3f2ed26..84107e9 100644 --- a/src/board.ts +++ b/src/board.ts @@ -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; diff --git a/src/events.ts b/src/events.ts index fc7f8e0..416932a 100644 --- a/src/events.ts +++ b/src/events.ts @@ -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);