cm-chessboard 4.3.7 → 4.3.9

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.
@@ -0,0 +1,21 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <link rel="stylesheet" href="../assets/styles/cm-chessboard.css">
5
+ <title>frame test</title>
6
+ </head>
7
+ <body>
8
+ Board:
9
+ <div id="board"></div>
10
+
11
+ <script type="module">
12
+ import { Chessboard, MARKER_TYPE } from '../src/cm-chessboard/Chessboard.js'
13
+
14
+ const board = new Chessboard(document.getElementById('board'), {
15
+ position: 'start',
16
+ sprite: {url: '../assets/images/chessboard-sprite.svg'},
17
+ style: {borderType: 'frame'}
18
+ })
19
+ </script>
20
+ </body>
21
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "4.3.7",
3
+ "version": "4.3.9",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",
@@ -97,7 +97,7 @@ export class Chessboard {
97
97
  this.view.redrawPieces()
98
98
  // instantiate extensions
99
99
  for (const extensionData of this.props.extensions) {
100
- new extensionData.class(this, extensionData.props)
100
+ this.extensions.push(new extensionData.class(this, extensionData.props))
101
101
  }
102
102
  }
103
103
 
@@ -44,14 +44,14 @@ export class VisualMoveInput {
44
44
  this.chessboard = view.chessboard
45
45
  this.moveStartCallback = (square) => {
46
46
  const result = moveStartCallback(square)
47
- if(result) {
47
+ if (result) {
48
48
  this.chessboard.moveTask = createTask()
49
49
  }
50
50
  return result
51
51
  }
52
52
  this.moveDoneCallback = (fromSquare, toSquare) => {
53
53
  const result = moveDoneCallback(fromSquare, toSquare)
54
- if(result) {
54
+ if (result) {
55
55
  this.chessboard.moveTask.resolve()
56
56
  } else {
57
57
  this.chessboard.moveTask.reject()
@@ -239,18 +239,18 @@ export class VisualMoveInput {
239
239
  onPointerDown(e) {
240
240
  if (e.type === "mousedown" && e.button === 0 || e.type === "touchstart") {
241
241
  const square = e.target.getAttribute("data-square")
242
- const pieceName = this.chessboard.getPiece(square)
243
- // console.log("onPointerDown", square, pieceName)
244
- let color
245
- if (pieceName) {
246
- color = pieceName ? pieceName.substring(0, 1) : undefined
247
- // allow scrolling, if not pointed on draggable piece
248
- if (color === "w" && this.chessboard.state.inputWhiteEnabled ||
249
- color === "b" && this.chessboard.state.inputBlackEnabled) {
250
- e.preventDefault()
251
- }
252
- }
253
242
  if (square) { // pointer on square
243
+ const pieceName = this.chessboard.getPiece(square)
244
+ // console.log("onPointerDown", square, pieceName)
245
+ let color
246
+ if (pieceName) {
247
+ color = pieceName ? pieceName.substring(0, 1) : undefined
248
+ // allow scrolling, if not pointed on draggable piece
249
+ if (color === "w" && this.chessboard.state.inputWhiteEnabled ||
250
+ color === "b" && this.chessboard.state.inputBlackEnabled) {
251
+ e.preventDefault()
252
+ }
253
+ }
254
254
  if (this.moveInputState !== STATE.waitForInputStart ||
255
255
  this.chessboard.state.inputWhiteEnabled && color === "w" ||
256
256
  this.chessboard.state.inputBlackEnabled && color === "b") {