cm-chessboard 8.12.3 → 8.12.4
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/README.md +43 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -152,10 +152,9 @@ this.props = {
|
|
|
152
152
|
|
|
153
153
|
### setPiece(square, piece, animated = false)
|
|
154
154
|
|
|
155
|
-
Sets a piece on a square. Example: `board.setPiece("e4", PIECE.
|
|
156
|
-
`board.setPiece("e4", "bn")`. Remove a
|
|
157
|
-
resolved
|
|
158
|
-
after the animation finished.
|
|
155
|
+
Sets a piece on a square. Example: `board.setPiece("e4", PIECE.bn, true)` or
|
|
156
|
+
`board.setPiece("e4", "bn")`. Remove a piece with `board.setPiece("e4", null)`. Returns a **Promise**, which is
|
|
157
|
+
resolved after the animation finished.
|
|
159
158
|
|
|
160
159
|
### getPiece(square)
|
|
161
160
|
|
|
@@ -177,9 +176,9 @@ Sets the position as `fen` or only the position part of a `fen`. Returns a **Pro
|
|
|
177
176
|
|
|
178
177
|
Returns the board position in form of the position part of a `fen`.
|
|
179
178
|
|
|
180
|
-
### setOrientation(color)
|
|
179
|
+
### setOrientation(color, animated = false)
|
|
181
180
|
|
|
182
|
-
Sets the board orientation (color at bottom). Allowed values are `COLOR.white` or `COLOR.black`.
|
|
181
|
+
Sets the board orientation (color at bottom). Allowed values are `COLOR.white` or `COLOR.black`. When `animated` is `true`, the board turns with an animation. Returns a **Promise**, which is resolved after the animation finished.
|
|
183
182
|
|
|
184
183
|
[Example for **setOrientation**](https://shaack.com/projekte/cm-chessboard/examples/enable-input.html)
|
|
185
184
|
|
|
@@ -187,12 +186,6 @@ Sets the board orientation (color at bottom). Allowed values are `COLOR.white` o
|
|
|
187
186
|
|
|
188
187
|
Returns the board orientation.
|
|
189
188
|
|
|
190
|
-
### destroy()
|
|
191
|
-
|
|
192
|
-
Removes the board from the DOM.
|
|
193
|
-
|
|
194
|
-
[Example for **destroy**](https://shaack.com/projekte/cm-chessboard/examples/destroy-many-boards.html)
|
|
195
|
-
|
|
196
189
|
### enableMoveInput(eventHandler, color = undefined)
|
|
197
190
|
|
|
198
191
|
Enables moves via user input (mouse or touch). Set optional `color`, if you want to enable the move input for a specific
|
|
@@ -247,6 +240,44 @@ chessboard.enableMoveInput((event) => {
|
|
|
247
240
|
|
|
248
241
|
Disables moves via user input.
|
|
249
242
|
|
|
243
|
+
### isMoveInputEnabled()
|
|
244
|
+
|
|
245
|
+
Returns `true` if move input is currently enabled for white or black.
|
|
246
|
+
|
|
247
|
+
### enableSquareSelect(eventType, eventHandler)
|
|
248
|
+
|
|
249
|
+
Listens for pointer events on squares and calls `eventHandler` with an object `{eventType, event, chessboard, square}`. `eventType` defaults to `POINTER_EVENTS.pointerdown`; allowed values are in `POINTER_EVENTS` (e.g. `pointerdown`, `pointerup`, `pointermove`, …).
|
|
250
|
+
|
|
251
|
+
```javascript
|
|
252
|
+
board.enableSquareSelect(POINTER_EVENTS.pointerdown, (event) => {
|
|
253
|
+
console.log(event.square)
|
|
254
|
+
})
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
[Example for **enableSquareSelect**](https://shaack.com/projekte/cm-chessboard/examples/pointer-events.html)
|
|
258
|
+
|
|
259
|
+
### disableSquareSelect(eventType)
|
|
260
|
+
|
|
261
|
+
Stops listening for the given pointer event type.
|
|
262
|
+
|
|
263
|
+
### isSquareSelectEnabled()
|
|
264
|
+
|
|
265
|
+
Returns `true` if square select is currently enabled.
|
|
266
|
+
|
|
267
|
+
### addExtension(extensionClass, props)
|
|
268
|
+
|
|
269
|
+
Adds an extension at runtime. Throws if the extension class is already added.
|
|
270
|
+
|
|
271
|
+
### getExtension(extensionClass)
|
|
272
|
+
|
|
273
|
+
Returns the instance of an added extension, or `null` if not found.
|
|
274
|
+
|
|
275
|
+
### destroy()
|
|
276
|
+
|
|
277
|
+
Removes the board from the DOM.
|
|
278
|
+
|
|
279
|
+
[Example for **destroy**](https://shaack.com/projekte/cm-chessboard/examples/destroy-many-boards.html)
|
|
280
|
+
|
|
250
281
|
## Piece sets
|
|
251
282
|
|
|
252
283
|
cm-chessboard supports alternative piece sets. A piece set is defined in an SVG sprite. cm-chessboard is shipped with
|