kokopu-react 1.8.0 → 1.9.0
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/lib/Chessboard.js +64 -67
- package/dist/lib/impl/ArrowTip.js +2 -2
- package/dist/lib/impl/Motion.js +133 -0
- package/graphic_test_src/05_chessboard_move.js +2 -2
- package/graphic_test_src/06a_chessboard_animated_move.js +36 -0
- package/graphic_test_src/06b_chessboard_animated_move.js +36 -0
- package/graphic_test_src/06c_chessboard_animated_move.js +36 -0
- package/graphic_test_src/{06_chessboard_theme.js → 07_chessboard_theme.js} +0 -0
- package/graphic_test_src/{07_chessboard_click_squares.js → 08_chessboard_click_squares.js} +0 -0
- package/graphic_test_src/{08_chessboard_move_pieces.js → 09_chessboard_move_pieces.js} +0 -0
- package/graphic_test_src/{09_chessboard_edit_arrows.js → 10_chessboard_edit_arrows.js} +0 -0
- package/graphic_test_src/{10_chessboard_play_moves.js → 11_chessboard_play_moves.js} +0 -0
- package/graphic_test_src/{11_chessboard_play_promotions.js → 12_chessboard_play_promotions.js} +0 -0
- package/graphic_test_src/{12_movetext_simple.js → 13_movetext_simple.js} +0 -0
- package/graphic_test_src/{13_movetext_error.js → 14_movetext_error.js} +0 -0
- package/graphic_test_src/{14_movetext_html.js → 15_movetext_html.js} +0 -0
- package/graphic_test_src/{15_movetext_options.js → 16_movetext_options.js} +0 -0
- package/graphic_test_src/{16_movetext_interaction.js → 17_movetext_interaction.js} +0 -0
- package/package.json +6 -8
- package/src/Chessboard.js +24 -20
- package/src/impl/ArrowTip.js +2 -2
- package/src/impl/Motion.js +99 -0
- package/test/4_chessboard_graphic.js +4 -1
- package/test/5_chessboard_interaction.js +5 -5
- package/test/6_chessboard_play_moves.js +4 -4
- package/test/7_movetext_graphic.js +4 -4
- package/test/8_movetext_interaction.js +2 -2
- package/test/common/graphic.js +6 -0
- package/test/references/06a_chessboard_animated_move/0.png +0 -0
- package/test/references/06a_chessboard_animated_move/1.png +0 -0
- package/test/references/06a_chessboard_animated_move/2.png +0 -0
- package/test/references/06a_chessboard_animated_move/3.png +0 -0
- package/test/references/06a_chessboard_animated_move/4.png +0 -0
- package/test/references/06a_chessboard_animated_move/5.png +0 -0
- package/test/references/06b_chessboard_animated_move/0.png +0 -0
- package/test/references/06b_chessboard_animated_move/1.png +0 -0
- package/test/references/06b_chessboard_animated_move/2.png +0 -0
- package/test/references/06b_chessboard_animated_move/3.png +0 -0
- package/test/references/06b_chessboard_animated_move/4.png +0 -0
- package/test/references/06b_chessboard_animated_move/5.png +0 -0
- package/test/references/06c_chessboard_animated_move/0.png +0 -0
- package/test/references/06c_chessboard_animated_move/1.png +0 -0
- package/test/references/06c_chessboard_animated_move/2.png +0 -0
- package/test/references/06c_chessboard_animated_move/3.png +0 -0
- package/test/references/06c_chessboard_animated_move/4.png +0 -0
- package/test/references/06c_chessboard_animated_move/5.png +0 -0
- package/test/references/{06_chessboard_theme → 07_chessboard_theme}/0.png +0 -0
- package/test/references/{06_chessboard_theme → 07_chessboard_theme}/1.png +0 -0
- package/test/references/{06_chessboard_theme → 07_chessboard_theme}/2.png +0 -0
- package/test/references/{06_chessboard_theme → 07_chessboard_theme}/3.png +0 -0
- package/test/references/{06_chessboard_theme → 07_chessboard_theme}/4.png +0 -0
- package/test/references/{06_chessboard_theme → 07_chessboard_theme}/5.png +0 -0
- package/test/references/{06_chessboard_theme → 07_chessboard_theme}/6.png +0 -0
- package/test/references/{06_chessboard_theme → 07_chessboard_theme}/7.png +0 -0
- package/test/references/{06_chessboard_theme → 07_chessboard_theme}/8.png +0 -0
- package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/after_move.png +0 -0
- package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/empty_square.png +0 -0
- package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/null_vector.png +0 -0
- package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/out_of_board.png +0 -0
- package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_arrow_marker.png +0 -0
- package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_empty.png +0 -0
- package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_non_empty_1.png +0 -0
- package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_non_empty_2.png +0 -0
- package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_square_marker.png +0 -0
- package/test/references/{08_chessboard_move_pieces → 09_chessboard_move_pieces}/over_text_marker.png +0 -0
- package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/base_1.png +0 -0
- package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/base_2.png +0 -0
- package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/edit_color_not_set.png +0 -0
- package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/null_vector.png +0 -0
- package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/out_of_board.png +0 -0
- package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/over_arrow_marker.png +0 -0
- package/test/references/{09_chessboard_edit_arrows → 10_chessboard_edit_arrows}/over_square_marker.png +0 -0
- package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/castling_move.png +0 -0
- package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/chess960_ambiguous_king_move.png +0 -0
- package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/chess960_castling_move_1.png +0 -0
- package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/chess960_castling_move_2.png +0 -0
- package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/chess960_non_kxr_castling.png +0 -0
- package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/illegal_move.png +0 -0
- package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/illegal_position.png +0 -0
- package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/null_vector.png +0 -0
- package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/out_of_board.png +0 -0
- package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/regular_move_1.png +0 -0
- package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/regular_move_2.png +0 -0
- package/test/references/{10_chessboard_play_moves → 11_chessboard_play_moves}/wrong_color.png +0 -0
- package/test/references/{11_chessboard_play_promotions → 12_chessboard_play_promotions}/antichess_promotion.png +0 -0
- package/test/references/{11_chessboard_play_promotions → 12_chessboard_play_promotions}/cancel_promotion.png +0 -0
- package/test/references/{11_chessboard_play_promotions → 12_chessboard_play_promotions}/regular_promotion_1.png +0 -0
- package/test/references/{11_chessboard_play_promotions → 12_chessboard_play_promotions}/regular_promotion_2.png +0 -0
- package/test/references/{12_movetext_simple → 13_movetext_simple}/0.png +0 -0
- package/test/references/{12_movetext_simple → 13_movetext_simple}/1.png +0 -0
- package/test/references/{12_movetext_simple → 13_movetext_simple}/2.png +0 -0
- package/test/references/{12_movetext_simple → 13_movetext_simple}/3.png +0 -0
- package/test/references/{13_movetext_error → 14_movetext_error}/0.png +0 -0
- package/test/references/{13_movetext_error → 14_movetext_error}/1.png +0 -0
- package/test/references/{13_movetext_error → 14_movetext_error}/2.png +0 -0
- package/test/references/{13_movetext_error → 14_movetext_error}/3.png +0 -0
- package/test/references/{13_movetext_error → 14_movetext_error}/4.png +0 -0
- package/test/references/{14_movetext_html → 15_movetext_html}/0.png +0 -0
- package/test/references/{14_movetext_html → 15_movetext_html}/1.png +0 -0
- package/test/references/{14_movetext_html → 15_movetext_html}/2.png +0 -0
- package/test/references/{15_movetext_options → 16_movetext_options}/0.png +0 -0
- package/test/references/{15_movetext_options → 16_movetext_options}/1.png +0 -0
- package/test/references/{15_movetext_options → 16_movetext_options}/2.png +0 -0
- package/test/references/{15_movetext_options → 16_movetext_options}/3.png +0 -0
- package/test/references/{16_movetext_interaction → 17_movetext_interaction}/0.png +0 -0
- package/test/references/{16_movetext_interaction → 17_movetext_interaction}/1.png +0 -0
- package/test/references/{16_movetext_interaction → 17_movetext_interaction}/2.png +0 -0
- package/CHANGELOG.md +0 -141
- package/graphics/chess_sprites/cburnett/bb.svg +0 -45
- package/graphics/chess_sprites/cburnett/bk.svg +0 -47
- package/graphics/chess_sprites/cburnett/bn.svg +0 -37
- package/graphics/chess_sprites/cburnett/bp.svg +0 -19
- package/graphics/chess_sprites/cburnett/bq.svg +0 -58
- package/graphics/chess_sprites/cburnett/br.svg +0 -60
- package/graphics/chess_sprites/cburnett/bx.svg +0 -56
- package/graphics/chess_sprites/cburnett/wb.svg +0 -48
- package/graphics/chess_sprites/cburnett/wk.svg +0 -26
- package/graphics/chess_sprites/cburnett/wn.svg +0 -37
- package/graphics/chess_sprites/cburnett/wp.svg +0 -19
- package/graphics/chess_sprites/cburnett/wq.svg +0 -60
- package/graphics/chess_sprites/cburnett/wr.svg +0 -44
- package/graphics/chess_sprites/cburnett/wx.svg +0 -56
- package/graphics/chess_sprites/generate_sprites.sh +0 -135
- package/graphics/chess_sprites/mmonge/celtic-bx.svg +0 -112
- package/graphics/chess_sprites/mmonge/celtic-wx.svg +0 -111
- package/graphics/chess_sprites/mmonge/celtic.svg +0 -1576
- package/graphics/chess_sprites/mmonge/eyes-spatial-bx.svg +0 -101
- package/graphics/chess_sprites/mmonge/eyes-spatial-wx.svg +0 -100
- package/graphics/chess_sprites/mmonge/eyes.svg +0 -2538
- package/graphics/chess_sprites/mmonge/fantasy-bx.svg +0 -112
- package/graphics/chess_sprites/mmonge/fantasy-wx.svg +0 -111
- package/graphics/chess_sprites/mmonge/fantasy.svg +0 -5497
- package/graphics/chess_sprites/mmonge/fantasy_alt.svg +0 -3742
- package/graphics/chess_sprites/mmonge/freak.svg +0 -3479
- package/graphics/chess_sprites/mmonge/prmi.svg +0 -6776
- package/graphics/chess_sprites/mmonge/skulls-bx.svg +0 -124
- package/graphics/chess_sprites/mmonge/skulls-wx.svg +0 -111
- package/graphics/chess_sprites/mmonge/skulls.svg +0 -12978
- package/graphics/chess_sprites/mmonge/spatial.svg +0 -1223
- package/graphics/logo-small.svg +0 -14
- package/graphics/logo.svg +0 -26
package/dist/lib/Chessboard.js
CHANGED
|
@@ -11,8 +11,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _reactDraggable = _interopRequireDefault(require("react-draggable"));
|
|
13
13
|
|
|
14
|
-
var _reactMotion = require("react-motion");
|
|
15
|
-
|
|
16
14
|
var _kokopu = require("kokopu");
|
|
17
15
|
|
|
18
16
|
var _colorsets2 = _interopRequireDefault(require("./impl/colorsets"));
|
|
@@ -21,6 +19,8 @@ var _piecesets2 = _interopRequireDefault(require("./impl/piecesets"));
|
|
|
21
19
|
|
|
22
20
|
var _ArrowTip = _interopRequireDefault(require("./impl/ArrowTip"));
|
|
23
21
|
|
|
22
|
+
var _Motion = _interopRequireDefault(require("./impl/Motion"));
|
|
23
|
+
|
|
24
24
|
var _TextSymbol = _interopRequireDefault(require("./impl/TextSymbol"));
|
|
25
25
|
|
|
26
26
|
var _ErrorBox = _interopRequireDefault(require("./ErrorBox"));
|
|
@@ -77,10 +77,7 @@ var FILE_COORDINATE_HEIGHT_FACTOR = 1.4;
|
|
|
77
77
|
var HOVER_MARKER_THICKNESS_FACTOR = 0.1;
|
|
78
78
|
var STROKE_THICKNESS_FACTOR = 0.15;
|
|
79
79
|
var ARROW_TIP_OFFSET_FACTOR = 0.3;
|
|
80
|
-
var
|
|
81
|
-
stiffness: 700,
|
|
82
|
-
damping: 40
|
|
83
|
-
};
|
|
80
|
+
var MOTION_DURATION = 150;
|
|
84
81
|
var RANK_LABELS = '12345678';
|
|
85
82
|
var FILE_LABELS = 'abcdefgh';
|
|
86
83
|
/**
|
|
@@ -107,28 +104,32 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
107
104
|
windowWidth: window.innerWidth
|
|
108
105
|
};
|
|
109
106
|
_this.arrowTipIdSuffix = (0, _util.generateRandomId)();
|
|
110
|
-
|
|
111
|
-
_this.windowResizeListener = function () {
|
|
112
|
-
return _this.handleWindowResize();
|
|
113
|
-
};
|
|
114
|
-
|
|
115
107
|
return _this;
|
|
116
108
|
}
|
|
117
109
|
|
|
118
110
|
_createClass(Chessboard, [{
|
|
119
111
|
key: "componentDidMount",
|
|
120
112
|
value: function componentDidMount() {
|
|
113
|
+
var _this2 = this;
|
|
114
|
+
|
|
115
|
+
this.windowResizeListener = function () {
|
|
116
|
+
return _this2.handleWindowResize();
|
|
117
|
+
};
|
|
118
|
+
|
|
121
119
|
window.addEventListener('resize', this.windowResizeListener);
|
|
122
120
|
}
|
|
123
121
|
}, {
|
|
124
122
|
key: "componentWillUnmount",
|
|
125
123
|
value: function componentWillUnmount() {
|
|
126
|
-
|
|
124
|
+
if (this.windowResizeListener) {
|
|
125
|
+
window.removeEventListener('resize', this.windowResizeListener);
|
|
126
|
+
this.windowResizeListener = null;
|
|
127
|
+
}
|
|
127
128
|
}
|
|
128
129
|
}, {
|
|
129
130
|
key: "render",
|
|
130
131
|
value: function render() {
|
|
131
|
-
var
|
|
132
|
+
var _this3 = this;
|
|
132
133
|
|
|
133
134
|
// Compute the current position.
|
|
134
135
|
var info = this.getPositionAndMoveInfo();
|
|
@@ -162,7 +163,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
162
163
|
|
|
163
164
|
var squares = [];
|
|
164
165
|
(0, _kokopu.forEachSquare)(function (sq) {
|
|
165
|
-
return squares.push(
|
|
166
|
+
return squares.push(_this3.renderSquare(squareSize, colorset, sq));
|
|
166
167
|
}); // Render coordinates.
|
|
167
168
|
|
|
168
169
|
var rankCoordinates = [];
|
|
@@ -191,19 +192,15 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
191
192
|
}, {
|
|
192
193
|
key: "renderBoardContent",
|
|
193
194
|
value: function renderBoardContent(position, positionBefore, move, squareSize, colorset, pieceset) {
|
|
194
|
-
var
|
|
195
|
+
var _this4 = this;
|
|
195
196
|
|
|
196
197
|
if (move && this.props.animated) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
alpha: (0, _reactMotion.spring)(1, ANIMATION_SPEED)
|
|
204
|
-
}
|
|
205
|
-
}, function (currentStyle) {
|
|
206
|
-
return currentStyle.alpha >= 1 ? _this3.renderBoardContentStill(position, move, squareSize, colorset, pieceset) : _this3.renderBoardContentAnimated(positionBefore, move, currentStyle.alpha, squareSize, colorset, pieceset);
|
|
198
|
+
var key = positionBefore.variant() + '|' + positionBefore.fen() + '|' + move.toString();
|
|
199
|
+
return /*#__PURE__*/_react["default"].createElement(_Motion["default"], {
|
|
200
|
+
key: key,
|
|
201
|
+
duration: MOTION_DURATION
|
|
202
|
+
}, function (motionCursor) {
|
|
203
|
+
return motionCursor === 1 ? _this4.renderBoardContentStill(position, move, squareSize, colorset, pieceset) : _this4.renderBoardContentAnimated(positionBefore, move, motionCursor, squareSize, colorset, pieceset);
|
|
207
204
|
});
|
|
208
205
|
} else {
|
|
209
206
|
return this.renderBoardContentStill(position, move, squareSize, colorset, pieceset);
|
|
@@ -215,14 +212,14 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
215
212
|
|
|
216
213
|
}, {
|
|
217
214
|
key: "renderBoardContentAnimated",
|
|
218
|
-
value: function renderBoardContentAnimated(positionBefore, move,
|
|
219
|
-
var
|
|
215
|
+
value: function renderBoardContentAnimated(positionBefore, move, motionCursor, squareSize, colorset, pieceset) {
|
|
216
|
+
var _this5 = this;
|
|
220
217
|
|
|
221
218
|
var pieces = [];
|
|
222
219
|
(0, _kokopu.forEachSquare)(function (sq) {
|
|
223
|
-
return pieces.push(
|
|
220
|
+
return pieces.push(_this5.renderPieceAnimated(positionBefore, move, motionCursor, squareSize, pieceset, sq));
|
|
224
221
|
});
|
|
225
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, pieces, this.renderMoveArrow(move,
|
|
222
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, pieces, this.renderMoveArrow(move, motionCursor, squareSize, colorset), this.renderTurnFlag((0, _kokopu.oppositeColor)(positionBefore.turn()), squareSize, pieceset));
|
|
226
223
|
}
|
|
227
224
|
/**
|
|
228
225
|
* Render the board content when the animation has been completed (or if there is no animation).
|
|
@@ -231,7 +228,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
231
228
|
}, {
|
|
232
229
|
key: "renderBoardContentStill",
|
|
233
230
|
value: function renderBoardContentStill(position, move, squareSize, colorset, pieceset) {
|
|
234
|
-
var
|
|
231
|
+
var _this6 = this;
|
|
235
232
|
|
|
236
233
|
// Compute the annotations.
|
|
237
234
|
var sqm = parseMarkers(this.props.squareMarkers, _markers.parseSquareMarkers, _util.isValidSquare, _util.isValidColor);
|
|
@@ -243,10 +240,10 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
243
240
|
var pieces = [];
|
|
244
241
|
var handles = [];
|
|
245
242
|
(0, _kokopu.forEachSquare)(function (sq) {
|
|
246
|
-
pieces.push(
|
|
243
|
+
pieces.push(_this6.renderPiece(position, squareSize, pieceset, sq));
|
|
247
244
|
|
|
248
|
-
if (
|
|
249
|
-
handles.push(
|
|
245
|
+
if (_this6.props.interactionMode) {
|
|
246
|
+
handles.push(_this6.renderSquareHandle(position, squareSize, sq));
|
|
250
247
|
}
|
|
251
248
|
});
|
|
252
249
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, this.renderSquareMarkers(sqm, squareSize, colorset), this.renderHoveredSquare(squareSize, colorset), pieces, this.renderTextMarkers(txtm, squareSize, colorset), this.renderArrowMarkers(arm, squareSize, colorset), this.renderMoveArrow(move, 1, squareSize, colorset), handles, this.renderPromotionDrawer(position, squareSize, colorset, pieceset), this.renderDraggedPiece(position, squareSize, pieceset), this.renderDraggedArrow(squareSize, colorset), this.renderTurnFlag(position.turn(), squareSize, pieceset));
|
|
@@ -315,7 +312,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
315
312
|
}
|
|
316
313
|
}, {
|
|
317
314
|
key: "renderPieceAnimated",
|
|
318
|
-
value: function renderPieceAnimated(positionBefore, move,
|
|
315
|
+
value: function renderPieceAnimated(positionBefore, move, motionCursor, squareSize, pieceset, sq) {
|
|
319
316
|
var cp = positionBefore.square(sq);
|
|
320
317
|
|
|
321
318
|
if (cp === '-' || move.to() === sq || move.isEnPassant() && move.enPassantSquare() === sq) {
|
|
@@ -331,10 +328,10 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
331
328
|
xTo = _this$getSquareCoordi5.x,
|
|
332
329
|
yTo = _this$getSquareCoordi5.y;
|
|
333
330
|
|
|
334
|
-
x = xTo *
|
|
335
|
-
y = yTo *
|
|
331
|
+
x = xTo * motionCursor + x * (1 - motionCursor);
|
|
332
|
+
y = yTo * motionCursor + y * (1 - motionCursor);
|
|
336
333
|
|
|
337
|
-
if (move.isPromotion() &&
|
|
334
|
+
if (move.isPromotion() && motionCursor > 0.8) {
|
|
338
335
|
cp = move.coloredPromotion();
|
|
339
336
|
}
|
|
340
337
|
} else if (move.isCastling() && sq === move.rookFrom()) {
|
|
@@ -342,8 +339,8 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
342
339
|
_xTo = _this$getSquareCoordi6.x,
|
|
343
340
|
_yTo = _this$getSquareCoordi6.y;
|
|
344
341
|
|
|
345
|
-
x = _xTo *
|
|
346
|
-
y = _yTo *
|
|
342
|
+
x = _xTo * motionCursor + x * (1 - motionCursor);
|
|
343
|
+
y = _yTo * motionCursor + y * (1 - motionCursor);
|
|
347
344
|
}
|
|
348
345
|
|
|
349
346
|
return /*#__PURE__*/_react["default"].createElement("image", {
|
|
@@ -410,7 +407,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
410
407
|
}, {
|
|
411
408
|
key: "renderPromotionDrawer",
|
|
412
409
|
value: function renderPromotionDrawer(position, squareSize, colorset, pieceset) {
|
|
413
|
-
var
|
|
410
|
+
var _this7 = this;
|
|
414
411
|
|
|
415
412
|
if (!this.state.promotionDrawer) {
|
|
416
413
|
return undefined;
|
|
@@ -434,7 +431,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
434
431
|
height: squareSize,
|
|
435
432
|
href: pieceset[cp],
|
|
436
433
|
onClick: function onClick() {
|
|
437
|
-
return
|
|
434
|
+
return _this7.handleDrawerButtonClicked(p);
|
|
438
435
|
}
|
|
439
436
|
});
|
|
440
437
|
});
|
|
@@ -445,7 +442,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
445
442
|
width: squareSize * 8,
|
|
446
443
|
height: squareSize * 8,
|
|
447
444
|
onClick: function onClick() {
|
|
448
|
-
return
|
|
445
|
+
return _this7.handleDrawerCancelButtonClicked();
|
|
449
446
|
}
|
|
450
447
|
}), /*#__PURE__*/_react["default"].createElement("rect", {
|
|
451
448
|
x: x,
|
|
@@ -465,7 +462,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
465
462
|
}, {
|
|
466
463
|
key: "renderSquareHandle",
|
|
467
464
|
value: function renderSquareHandle(position, squareSize, sq) {
|
|
468
|
-
var
|
|
465
|
+
var _this8 = this;
|
|
469
466
|
|
|
470
467
|
var _this$getSquareCoordi10 = this.getSquareCoordinates(squareSize, sq),
|
|
471
468
|
x = _this$getSquareCoordi10.x,
|
|
@@ -485,13 +482,13 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
485
482
|
key: 'handle-' + sq,
|
|
486
483
|
position: dragPosition,
|
|
487
484
|
onStart: function onStart(evt) {
|
|
488
|
-
return
|
|
485
|
+
return _this8.handleDragStart(sq, evt);
|
|
489
486
|
},
|
|
490
487
|
onDrag: function onDrag(_, dragData) {
|
|
491
|
-
return
|
|
488
|
+
return _this8.handleDrag(sq, dragData);
|
|
492
489
|
},
|
|
493
490
|
onStop: function onStop(_, dragData) {
|
|
494
|
-
return
|
|
491
|
+
return _this8.handleDragStop(sq, dragData);
|
|
495
492
|
}
|
|
496
493
|
}, /*#__PURE__*/_react["default"].createElement("rect", {
|
|
497
494
|
className: classNames.join(' '),
|
|
@@ -509,7 +506,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
509
506
|
width: squareSize,
|
|
510
507
|
height: squareSize,
|
|
511
508
|
onClick: function onClick() {
|
|
512
|
-
return
|
|
509
|
+
return _this8.handleSquareClicked(sq);
|
|
513
510
|
}
|
|
514
511
|
});
|
|
515
512
|
} else {
|
|
@@ -519,7 +516,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
519
516
|
}, {
|
|
520
517
|
key: "renderSquareMarkers",
|
|
521
518
|
value: function renderSquareMarkers(sqm, squareSize, colorset) {
|
|
522
|
-
var
|
|
519
|
+
var _this9 = this;
|
|
523
520
|
|
|
524
521
|
var result = [];
|
|
525
522
|
Object.entries(sqm).forEach(function (_ref) {
|
|
@@ -527,9 +524,9 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
527
524
|
sq = _ref2[0],
|
|
528
525
|
color = _ref2[1];
|
|
529
526
|
|
|
530
|
-
var
|
|
531
|
-
x =
|
|
532
|
-
y =
|
|
527
|
+
var _this9$getSquareCoord = _this9.getSquareCoordinates(squareSize, sq),
|
|
528
|
+
x = _this9$getSquareCoord.x,
|
|
529
|
+
y = _this9$getSquareCoord.y;
|
|
533
530
|
|
|
534
531
|
result.push( /*#__PURE__*/_react["default"].createElement("rect", {
|
|
535
532
|
key: 'sqm-' + sq,
|
|
@@ -546,7 +543,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
546
543
|
}, {
|
|
547
544
|
key: "renderTextMarkers",
|
|
548
545
|
value: function renderTextMarkers(txtm, squareSize, colorset) {
|
|
549
|
-
var
|
|
546
|
+
var _this10 = this;
|
|
550
547
|
|
|
551
548
|
var result = [];
|
|
552
549
|
Object.entries(txtm).forEach(function (_ref3) {
|
|
@@ -554,9 +551,9 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
554
551
|
sq = _ref4[0],
|
|
555
552
|
value = _ref4[1];
|
|
556
553
|
|
|
557
|
-
var
|
|
558
|
-
x =
|
|
559
|
-
y =
|
|
554
|
+
var _this10$getSquareCoor = _this10.getSquareCoordinates(squareSize, sq),
|
|
555
|
+
x = _this10$getSquareCoor.x,
|
|
556
|
+
y = _this10$getSquareCoor.y;
|
|
560
557
|
|
|
561
558
|
x += squareSize / 2;
|
|
562
559
|
y += squareSize / 2;
|
|
@@ -576,7 +573,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
576
573
|
}, {
|
|
577
574
|
key: "renderArrowMarkers",
|
|
578
575
|
value: function renderArrowMarkers(arm, squareSize, colorset) {
|
|
579
|
-
var
|
|
576
|
+
var _this11 = this;
|
|
580
577
|
|
|
581
578
|
var result = [];
|
|
582
579
|
var strokeWidth = squareSize * STROKE_THICKNESS_FACTOR;
|
|
@@ -592,13 +589,13 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
592
589
|
return;
|
|
593
590
|
}
|
|
594
591
|
|
|
595
|
-
var
|
|
596
|
-
xFrom =
|
|
597
|
-
yFrom =
|
|
592
|
+
var _this11$getSquareCoor = _this11.getSquareCoordinates(squareSize, from),
|
|
593
|
+
xFrom = _this11$getSquareCoor.x,
|
|
594
|
+
yFrom = _this11$getSquareCoor.y;
|
|
598
595
|
|
|
599
|
-
var
|
|
600
|
-
xTo =
|
|
601
|
-
yTo =
|
|
596
|
+
var _this11$getSquareCoor2 = _this11.getSquareCoordinates(squareSize, to),
|
|
597
|
+
xTo = _this11$getSquareCoor2.x,
|
|
598
|
+
yTo = _this11$getSquareCoor2.y;
|
|
602
599
|
|
|
603
600
|
xFrom += squareSize / 2;
|
|
604
601
|
yFrom += squareSize / 2;
|
|
@@ -607,7 +604,7 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
607
604
|
xTo += Math.sign(xFrom - xTo) * ARROW_TIP_OFFSET_FACTOR * squareSize;
|
|
608
605
|
yTo += Math.sign(yFrom - yTo) * ARROW_TIP_OFFSET_FACTOR * squareSize;
|
|
609
606
|
|
|
610
|
-
var arrowTipId =
|
|
607
|
+
var arrowTipId = _this11.getArrowTipId(color);
|
|
611
608
|
|
|
612
609
|
result.push( /*#__PURE__*/_react["default"].createElement("line", {
|
|
613
610
|
key: 'arm-' + vect,
|
|
@@ -625,8 +622,8 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
625
622
|
}
|
|
626
623
|
}, {
|
|
627
624
|
key: "renderMoveArrow",
|
|
628
|
-
value: function renderMoveArrow(move,
|
|
629
|
-
if (!move ||
|
|
625
|
+
value: function renderMoveArrow(move, motionCursor, squareSize, colorset) {
|
|
626
|
+
if (!move || motionCursor < 0.1 || !this.props.moveArrowVisible || move.from() === move.to()) {
|
|
630
627
|
return undefined;
|
|
631
628
|
}
|
|
632
629
|
|
|
@@ -645,8 +642,8 @@ var Chessboard = /*#__PURE__*/function (_React$Component) {
|
|
|
645
642
|
yTo += squareSize / 2;
|
|
646
643
|
xTo += Math.sign(xFrom - xTo) * ARROW_TIP_OFFSET_FACTOR * squareSize;
|
|
647
644
|
yTo += Math.sign(yFrom - yTo) * ARROW_TIP_OFFSET_FACTOR * squareSize;
|
|
648
|
-
var x = xTo *
|
|
649
|
-
var y = yTo *
|
|
645
|
+
var x = xTo * motionCursor + xFrom * (1 - motionCursor);
|
|
646
|
+
var y = yTo * motionCursor + yFrom * (1 - motionCursor);
|
|
650
647
|
var color = this.props.moveArrowColor;
|
|
651
648
|
return /*#__PURE__*/_react["default"].createElement("line", {
|
|
652
649
|
className: "kokopu-annotation kokopu-arrow",
|
|
@@ -42,9 +42,9 @@ function ArrowTip(props) {
|
|
|
42
42
|
markerHeight: 4,
|
|
43
43
|
refX: 2.5,
|
|
44
44
|
refY: 2,
|
|
45
|
-
orient: "auto"
|
|
46
|
-
fill: props.color
|
|
45
|
+
orient: "auto"
|
|
47
46
|
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
47
|
+
fill: props.color,
|
|
48
48
|
d: "M 4,2 L 0,4 L 1,2 L 0,0 Z"
|
|
49
49
|
}));
|
|
50
50
|
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
+
|
|
16
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
+
|
|
18
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
19
|
+
|
|
20
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
21
|
+
|
|
22
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
23
|
+
|
|
24
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
25
|
+
|
|
26
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
27
|
+
|
|
28
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
29
|
+
|
|
30
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
31
|
+
|
|
32
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
33
|
+
|
|
34
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
35
|
+
|
|
36
|
+
var DEBUG_KEY = '__kokopu_debug_freeze_motion';
|
|
37
|
+
/**
|
|
38
|
+
* Wrap some animated content.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
var Motion = /*#__PURE__*/function (_React$Component) {
|
|
42
|
+
_inherits(Motion, _React$Component);
|
|
43
|
+
|
|
44
|
+
var _super = _createSuper(Motion);
|
|
45
|
+
|
|
46
|
+
function Motion(props) {
|
|
47
|
+
var _this;
|
|
48
|
+
|
|
49
|
+
_classCallCheck(this, Motion);
|
|
50
|
+
|
|
51
|
+
_this = _super.call(this, props);
|
|
52
|
+
_this.state = {
|
|
53
|
+
cursor: 0
|
|
54
|
+
};
|
|
55
|
+
_this.animationFrameId = null;
|
|
56
|
+
_this.cursorStop = 1; // WARNING: this hack exists only for testing purposes. DO NOT USE IT IN PRODUCTION.
|
|
57
|
+
|
|
58
|
+
if (typeof window[DEBUG_KEY] === 'number' && window[DEBUG_KEY] >= 0 && window[DEBUG_KEY] <= 1) {
|
|
59
|
+
_this.cursorStop = window[DEBUG_KEY];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return _this;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
_createClass(Motion, [{
|
|
66
|
+
key: "componentDidMount",
|
|
67
|
+
value: function componentDidMount() {
|
|
68
|
+
var _this2 = this;
|
|
69
|
+
|
|
70
|
+
this.animationFrameId = window.requestAnimationFrame(function (ts) {
|
|
71
|
+
return _this2.handleAnimationStep(ts);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "componentWillUnmount",
|
|
76
|
+
value: function componentWillUnmount() {
|
|
77
|
+
if (this.animationFrameId !== null) {
|
|
78
|
+
window.cancelAnimationFrame(this.animationFrameId);
|
|
79
|
+
this.animationFrameId = null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
key: "handleAnimationStep",
|
|
84
|
+
value: function handleAnimationStep(timestamp) {
|
|
85
|
+
var _this3 = this;
|
|
86
|
+
|
|
87
|
+
if (this.initialTimestamp === undefined) {
|
|
88
|
+
this.initialTimestamp = timestamp;
|
|
89
|
+
} // Compute the animation cursor and update the state.
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
var cursor = (timestamp - this.initialTimestamp) / this.props.duration;
|
|
93
|
+
|
|
94
|
+
if (cursor < 0) {
|
|
95
|
+
cursor = 0;
|
|
96
|
+
} else if (cursor > this.cursorStop) {
|
|
97
|
+
cursor = this.cursorStop;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this.setState({
|
|
101
|
+
cursor: cursor
|
|
102
|
+
}); // Schedule the next animation frame if necessary.
|
|
103
|
+
|
|
104
|
+
if (cursor === this.cursorStop) {
|
|
105
|
+
this.animationFrameId = null;
|
|
106
|
+
} else {
|
|
107
|
+
this.animationFrameId = window.requestAnimationFrame(function (ts) {
|
|
108
|
+
return _this3.handleAnimationStep(ts);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
key: "render",
|
|
114
|
+
value: function render() {
|
|
115
|
+
return this.props.children(this.state.cursor);
|
|
116
|
+
}
|
|
117
|
+
}]);
|
|
118
|
+
|
|
119
|
+
return Motion;
|
|
120
|
+
}(_react["default"].Component);
|
|
121
|
+
|
|
122
|
+
exports["default"] = Motion;
|
|
123
|
+
Motion.propTypes = {
|
|
124
|
+
/**
|
|
125
|
+
* Duration of the animation. Must be > 0.
|
|
126
|
+
*/
|
|
127
|
+
duration: _propTypes["default"].number.isRequired,
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Factory for the content being animated. The animation cursor is guaranteed to be valued between 0 and 1 inclusive.
|
|
131
|
+
*/
|
|
132
|
+
children: _propTypes["default"].func.isRequired
|
|
133
|
+
};
|
|
@@ -32,8 +32,8 @@ testApp([ /* eslint-disable react/jsx-key */
|
|
|
32
32
|
<Chessboard move="e4" animated={false} />,
|
|
33
33
|
<Chessboard move="Nf3" moveArrowVisible={false} animated={false} />,
|
|
34
34
|
<Chessboard move="Nf4" animated={false} />,
|
|
35
|
-
<Chessboard position="rnbqkbnr/pppp1ppp/4p3/8/3PP3/8/PPP2PPP/RNBQKBNR b KQkq - 0 2" move="Bb4+" moveArrowVisible={true} flipped={true} animated={
|
|
36
|
-
<Chessboard position={pos} move={move} animated={
|
|
35
|
+
<Chessboard position="rnbqkbnr/pppp1ppp/4p3/8/3PP3/8/PPP2PPP/RNBQKBNR b KQkq - 0 2" move="Bb4+" moveArrowVisible={true} flipped={true} animated={true} />,
|
|
36
|
+
<Chessboard position={pos} move={move} animated={true} moveArrowColor="g" />,
|
|
37
37
|
<Chessboard position="r3k2r/pppppppp/8/8/8/8/PPPPPPPP/R3K2R b KQkq - 0 1" move="O-O-O" animated={false} moveArrowColor="r" />,
|
|
38
38
|
<Chessboard position="rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3" move="exf6" animated={false} moveArrowColor="y" />,
|
|
39
39
|
<Chessboard position="8/8/8/1K6/8/4k3/1p6/8 b - - 0 1" move="b1=R+" animated={false} moveArrowColor="b" />,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* *
|
|
3
|
+
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
|
+
* *
|
|
6
|
+
* This program is free software: you can redistribute it and/or *
|
|
7
|
+
* modify it under the terms of the GNU Lesser General Public License *
|
|
8
|
+
* as published by the Free Software Foundation, either version 3 of *
|
|
9
|
+
* the License, or (at your option) any later version. *
|
|
10
|
+
* *
|
|
11
|
+
* This program is distributed in the hope that it will be useful, *
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
14
|
+
* GNU Lesser General Public License for more details. *
|
|
15
|
+
* *
|
|
16
|
+
* You should have received a copy of the GNU Lesser General *
|
|
17
|
+
* Public License along with this program. If not, see *
|
|
18
|
+
* <http://www.gnu.org/licenses/>. *
|
|
19
|
+
* *
|
|
20
|
+
******************************************************************************/
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
import React from 'react';
|
|
24
|
+
import testApp from './common/test_app';
|
|
25
|
+
import { Chessboard } from '../src/index';
|
|
26
|
+
|
|
27
|
+
window['__kokopu_debug_freeze_motion'] = 0.09;
|
|
28
|
+
|
|
29
|
+
testApp([ /* eslint-disable react/jsx-key */
|
|
30
|
+
<Chessboard move="e4" animated={true} />,
|
|
31
|
+
<Chessboard move="Nf3" animated={true} moveArrowVisible={false} />,
|
|
32
|
+
<Chessboard position="r1bqkbnr/pppppppp/n7/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 1 2" move="Bxa6" animated={true} flipped />,
|
|
33
|
+
<Chessboard position="r3k2r/pppppppp/8/8/8/8/PPPPPPPP/R3K2R b KQkq - 0 1" move="O-O-O" animated={true} />,
|
|
34
|
+
<Chessboard position="rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3" move="exf6" animated={true} />,
|
|
35
|
+
<Chessboard position="8/8/8/1K6/8/4k3/1p6/8 b - - 0 1" move="b1=R+" animated={true} />,
|
|
36
|
+
]); /* eslint-enable react/jsx-key */
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* *
|
|
3
|
+
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
|
+
* *
|
|
6
|
+
* This program is free software: you can redistribute it and/or *
|
|
7
|
+
* modify it under the terms of the GNU Lesser General Public License *
|
|
8
|
+
* as published by the Free Software Foundation, either version 3 of *
|
|
9
|
+
* the License, or (at your option) any later version. *
|
|
10
|
+
* *
|
|
11
|
+
* This program is distributed in the hope that it will be useful, *
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
14
|
+
* GNU Lesser General Public License for more details. *
|
|
15
|
+
* *
|
|
16
|
+
* You should have received a copy of the GNU Lesser General *
|
|
17
|
+
* Public License along with this program. If not, see *
|
|
18
|
+
* <http://www.gnu.org/licenses/>. *
|
|
19
|
+
* *
|
|
20
|
+
******************************************************************************/
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
import React from 'react';
|
|
24
|
+
import testApp from './common/test_app';
|
|
25
|
+
import { Chessboard } from '../src/index';
|
|
26
|
+
|
|
27
|
+
window['__kokopu_debug_freeze_motion'] = 0.7;
|
|
28
|
+
|
|
29
|
+
testApp([ /* eslint-disable react/jsx-key */
|
|
30
|
+
<Chessboard move="e4" animated={true} />,
|
|
31
|
+
<Chessboard move="Nf3" animated={true} moveArrowVisible={false} />,
|
|
32
|
+
<Chessboard position="r1bqkbnr/pppppppp/n7/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 1 2" move="Bxa6" animated={true} flipped />,
|
|
33
|
+
<Chessboard position="r3k2r/pppppppp/8/8/8/8/PPPPPPPP/R3K2R b KQkq - 0 1" move="O-O-O" animated={true} />,
|
|
34
|
+
<Chessboard position="rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3" move="exf6" animated={true} />,
|
|
35
|
+
<Chessboard position="8/8/8/1K6/8/4k3/1p6/8 b - - 0 1" move="b1=R+" animated={true} />,
|
|
36
|
+
]); /* eslint-enable react/jsx-key */
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
* *
|
|
3
|
+
* This file is part of Kokopu-React, a JavaScript chess library. *
|
|
4
|
+
* Copyright (C) 2021-2022 Yoann Le Montagner <yo35 -at- melix.net> *
|
|
5
|
+
* *
|
|
6
|
+
* This program is free software: you can redistribute it and/or *
|
|
7
|
+
* modify it under the terms of the GNU Lesser General Public License *
|
|
8
|
+
* as published by the Free Software Foundation, either version 3 of *
|
|
9
|
+
* the License, or (at your option) any later version. *
|
|
10
|
+
* *
|
|
11
|
+
* This program is distributed in the hope that it will be useful, *
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
14
|
+
* GNU Lesser General Public License for more details. *
|
|
15
|
+
* *
|
|
16
|
+
* You should have received a copy of the GNU Lesser General *
|
|
17
|
+
* Public License along with this program. If not, see *
|
|
18
|
+
* <http://www.gnu.org/licenses/>. *
|
|
19
|
+
* *
|
|
20
|
+
******************************************************************************/
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
import React from 'react';
|
|
24
|
+
import testApp from './common/test_app';
|
|
25
|
+
import { Chessboard } from '../src/index';
|
|
26
|
+
|
|
27
|
+
window['__kokopu_debug_freeze_motion'] = 0.91;
|
|
28
|
+
|
|
29
|
+
testApp([ /* eslint-disable react/jsx-key */
|
|
30
|
+
<Chessboard move="e4" animated={true} />,
|
|
31
|
+
<Chessboard move="Nf3" animated={true} moveArrowVisible={false} />,
|
|
32
|
+
<Chessboard position="r1bqkbnr/pppppppp/n7/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 1 2" move="Bxa6" animated={true} flipped />,
|
|
33
|
+
<Chessboard position="r3k2r/pppppppp/8/8/8/8/PPPPPPPP/R3K2R b KQkq - 0 1" move="O-O-O" animated={true} />,
|
|
34
|
+
<Chessboard position="rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3" move="exf6" animated={true} />,
|
|
35
|
+
<Chessboard position="8/8/8/1K6/8/4k3/1p6/8 b - - 0 1" move="b1=R+" animated={true} />,
|
|
36
|
+
]); /* eslint-enable react/jsx-key */
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/graphic_test_src/{11_chessboard_play_promotions.js → 12_chessboard_play_promotions.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|