Prevent index out of range

This commit is contained in:
Christoph Hagen 2023-01-11 18:30:54 +01:00
parent b5a8fc8e22
commit 0cdae05f68

View File

@ -78,6 +78,10 @@ imageCanvas.addEventListener("click", function(event) {
const currentPosition = row * numberOfColumns + column;
if (currentPosition >= numberOfCaps) {
return;
}
if (selectedPosition === null) {
selectedPosition = currentPosition;
const circlePositionX = rowIsEven ? column * capImageSize + halfCapImageSize : column * capImageSize;