react-chessboard-ui 1.4.9 → 1.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +7 -3
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useEffect, useMemo, useCallback } from 'react';
|
|
1
|
+
import React, { useState, useEffect, useRef, useMemo, useCallback } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
|
|
4
4
|
function _arrayLikeToArray(r, a) {
|
|
@@ -173,6 +173,7 @@ JSChessEngine.checkBeatedCell = function (state, target) {
|
|
|
173
173
|
};
|
|
174
174
|
JSChessEngine.hasFigure = function (state, pos) {
|
|
175
175
|
var _state$pos$1$pos$;
|
|
176
|
+
if (!state[pos[1]]) return false;
|
|
176
177
|
return !!((_state$pos$1$pos$ = state[pos[1]][pos[0]]) !== null && _state$pos$1$pos$ !== void 0 && _state$pos$1$pos$.figure);
|
|
177
178
|
};
|
|
178
179
|
JSChessEngine.checkFigureIsLongRange = function (state, figurePos) {
|
|
@@ -1041,7 +1042,7 @@ JSChessEngine.getGameResult = function (state, linesWithCheck, activeColor, reve
|
|
|
1041
1042
|
});
|
|
1042
1043
|
var countsSumResult = countsNextMoves.reduce(function (prevValue, curentValue) {
|
|
1043
1044
|
return prevValue + curentValue;
|
|
1044
|
-
});
|
|
1045
|
+
}, 0);
|
|
1045
1046
|
if (linesWithCheck.length > 0 && countsSumResult === 0) return {
|
|
1046
1047
|
resultType: 'mat',
|
|
1047
1048
|
winColor: activeColor === 'white' ? 'black' : 'white'
|
|
@@ -2380,13 +2381,16 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
|
|
|
2380
2381
|
var clearArrows = function clearArrows() {
|
|
2381
2382
|
return setArrowsCoords([]);
|
|
2382
2383
|
};
|
|
2384
|
+
var firstRender = useRef(false);
|
|
2383
2385
|
useEffect(function () {
|
|
2384
2386
|
setBoardConfig(getChessBoardConfig(config));
|
|
2385
2387
|
}, []);
|
|
2386
2388
|
useEffect(function () {
|
|
2387
|
-
if (
|
|
2389
|
+
if (firstRender.current) {
|
|
2388
2390
|
var gameResult = JSChessEngine.getGameResult(actualState, linesWithCheck, currentColor, boardReversed);
|
|
2389
2391
|
if (gameResult) onEndGame(gameResult);
|
|
2392
|
+
} else {
|
|
2393
|
+
firstRender.current = true;
|
|
2390
2394
|
}
|
|
2391
2395
|
}, [actualState, linesWithCheck, boardReversed, currentColor]);
|
|
2392
2396
|
var cleanAllForFigure = function cleanAllForFigure() {
|