cm-chessboard 8.12.2 → 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.
Files changed (2) hide show
  1. package/README.md +48 -12
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -84,7 +84,12 @@ You can also copy the `assets` folder from `cm-chessboard/assets` to your projec
84
84
 
85
85
  To enable the user to move the pieces, you have to enable the move input.
86
86
 
87
+ Markers are provided by the [Markers extension](https://shaack.com/projekte/cm-chessboard/examples/extensions/markers-extension.html) (not part of the core), so you need to import and enable it.
88
+
87
89
  ```javascript
90
+ import {Chessboard, FEN, INPUT_EVENT_TYPE} from "./path/to/Chessboard.js"
91
+ import {Markers} from "./path/to/extensions/markers/Markers.js"
92
+
88
93
  const board = new Chessboard(document.getElementById("board"), {
89
94
  position: FEN.start,
90
95
  assetsUrl: "../assets/",
@@ -147,10 +152,9 @@ this.props = {
147
152
 
148
153
  ### setPiece(square, piece, animated = false)
149
154
 
150
- Sets a piece on a square. Example: `board.setPiece("e4", PIECE.blackKnight, true)` or
151
- `board.setPiece("e4", "bn")`. Remove a Piece with `board.setPiece("e4", null)`. Returns a **Promise**, which is
152
- resolved,
153
- 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.
154
158
 
155
159
  ### getPiece(square)
156
160
 
@@ -172,9 +176,9 @@ Sets the position as `fen` or only the position part of a `fen`. Returns a **Pro
172
176
 
173
177
  Returns the board position in form of the position part of a `fen`.
174
178
 
175
- ### setOrientation(color)
179
+ ### setOrientation(color, animated = false)
176
180
 
177
- 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.
178
182
 
179
183
  [Example for **setOrientation**](https://shaack.com/projekte/cm-chessboard/examples/enable-input.html)
180
184
 
@@ -182,12 +186,6 @@ Sets the board orientation (color at bottom). Allowed values are `COLOR.white` o
182
186
 
183
187
  Returns the board orientation.
184
188
 
185
- ### destroy()
186
-
187
- Removes the board from the DOM.
188
-
189
- [Example for **destroy**](https://shaack.com/projekte/cm-chessboard/examples/destroy-many-boards.html)
190
-
191
189
  ### enableMoveInput(eventHandler, color = undefined)
192
190
 
193
191
  Enables moves via user input (mouse or touch). Set optional `color`, if you want to enable the move input for a specific
@@ -242,6 +240,44 @@ chessboard.enableMoveInput((event) => {
242
240
 
243
241
  Disables moves via user input.
244
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
+
245
281
  ## Piece sets
246
282
 
247
283
  cm-chessboard supports alternative piece sets. A piece set is defined in an SVG sprite. cm-chessboard is shipped with
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "8.12.2",
3
+ "version": "8.12.4",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",