cm-chessboard 7.9.1 → 7.10.1
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 +19 -18
- package/package.json +1 -1
- package/src/Chessboard.js +2 -1
- package/src/view/VisualMoveInput.js +7 -6
package/README.md
CHANGED
|
@@ -88,25 +88,26 @@ Below is the default configuration
|
|
|
88
88
|
|
|
89
89
|
```javascript
|
|
90
90
|
this.props = {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
},
|
|
107
|
-
animationDuration: 300 // pieces animation duration in milliseconds. Disable all animations with `0`.
|
|
91
|
+
position: FEN.empty, // set position as fen, use FEN.start or FEN.empty as shortcuts
|
|
92
|
+
orientation: COLOR.white, // white on bottom
|
|
93
|
+
responsive: true, // resize the board automatically to the size of the context element
|
|
94
|
+
language: navigator.language.substring(0, 2).toLowerCase(), // supports "de" and "en" for now, used for pieces naming
|
|
95
|
+
assetsUrl: "./assets/", // put all css and sprites in this folder, will be ignored for absolute urls of assets files
|
|
96
|
+
assetsCache: true, // cache sprites
|
|
97
|
+
style: {
|
|
98
|
+
cssClass: "default", // set the css theme of the board, try "green", "blue" or "chess-club"
|
|
99
|
+
showCoordinates: true, // show ranks and files
|
|
100
|
+
borderType: BORDER_TYPE.none, // "thin" thin border, "frame" wide border with coordinates in it, "none" no border
|
|
101
|
+
aspectRatio: 1, // height/width of the board
|
|
102
|
+
pieces: {
|
|
103
|
+
type: PIECES_FILE_TYPE.svgSprite, // pieces are in an SVG sprite, no other type supported for now
|
|
104
|
+
file: "pieces/standard.svg", // the filename of the sprite in `assets/pieces/` or an absolute url like `https://…` or `/…`
|
|
105
|
+
tileSize: 40 // the tile size in the sprite
|
|
108
106
|
},
|
|
109
|
-
|
|
107
|
+
// pieces animation duration in milliseconds. Disable all animations with `0`. Respects the operating system settings for reduced motion.
|
|
108
|
+
animationDuration: window.matchMedia("(prefers-reduced-motion: reduce)").matches ? 0 : 300
|
|
109
|
+
},
|
|
110
|
+
extensions: [ /* {class: ExtensionClass, props: { ... }} */] // add extensions here
|
|
110
111
|
}
|
|
111
112
|
```
|
|
112
113
|
|
package/package.json
CHANGED
package/src/Chessboard.js
CHANGED
|
@@ -70,7 +70,8 @@ export class Chessboard {
|
|
|
70
70
|
file: "pieces/standard.svg", // the filename of the sprite in `assets/pieces/` or an absolute url like `https://…` or `/…`
|
|
71
71
|
tileSize: 40 // the tile size in the sprite
|
|
72
72
|
},
|
|
73
|
-
|
|
73
|
+
// pieces animation duration in milliseconds. Disable all animations with `0`. Respects the operating system settings for reduced motion.
|
|
74
|
+
animationDuration: window.matchMedia("(prefers-reduced-motion: reduce)").matches ? 0 : 300
|
|
74
75
|
},
|
|
75
76
|
extensions: [ /* {class: ExtensionClass, props: { ... }} */] // add extensions here
|
|
76
77
|
}
|
|
@@ -65,8 +65,8 @@ export class VisualMoveInput {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
moveInputCanceledCallback(fromSquare, toSquare, reason) {
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
this.view.moveInputCanceledCallback(fromSquare, toSquare, reason)
|
|
69
|
+
this.chessboard.state.moveInputProcess.resolve()
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
setMoveInputState(newState, params = undefined) {
|
|
@@ -240,14 +240,15 @@ export class VisualMoveInput {
|
|
|
240
240
|
|
|
241
241
|
onPointerDown(e) {
|
|
242
242
|
if (!(e.type === "mousedown" && e.button === 0 || e.type === "touchstart")) {
|
|
243
|
-
return
|
|
243
|
+
return
|
|
244
|
+
}
|
|
245
|
+
if(e.type === "mousedown") { // another try to prevent strange safari desktop select all bug
|
|
246
|
+
e.preventDefault()
|
|
244
247
|
}
|
|
245
|
-
|
|
246
248
|
const square = e.target.getAttribute("data-square")
|
|
247
249
|
if (!square) { // pointer on square
|
|
248
|
-
return
|
|
250
|
+
return
|
|
249
251
|
}
|
|
250
|
-
|
|
251
252
|
const pieceName = this.chessboard.getPiece(square)
|
|
252
253
|
let color
|
|
253
254
|
if (pieceName) {
|