cm-chessboard 7.7.3 → 7.7.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.
@@ -59,7 +59,7 @@ function inputHandler(event) {
59
59
  window.board.enableMoveInput(inputHandler)
60
60
 
61
61
  function inputHandler(event) {
62
- // console.log(event)
62
+ console.log(event)
63
63
  switch (event.type) {
64
64
  case INPUT_EVENT_TYPE.moveInputStarted:
65
65
  log(`moveInputStarted: ${event.squareFrom}`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "7.7.3",
3
+ "version": "7.7.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",
package/src/Chessboard.js CHANGED
@@ -88,6 +88,7 @@ export class Chessboard {
88
88
  this.state.position = new Position(this.props.position)
89
89
  this.view.redrawPieces()
90
90
  this.state.invokeExtensionPoints(EXTENSION_POINT.positionChanged)
91
+ this.initialized = Promise.resolve()
91
92
  }
92
93
 
93
94
  // API //
@@ -8,14 +8,14 @@ import {Svg} from "../lib/Svg.js"
8
8
  import {Utils} from "../lib/Utils.js"
9
9
 
10
10
  const MOVE_INPUT_STATE = {
11
- waitForInputStart: 0,
12
- pieceClickedThreshold: 1,
13
- clickTo: 2,
14
- secondClickThreshold: 3,
15
- dragTo: 4,
16
- clickDragTo: 5,
17
- moveDone: 6,
18
- reset: 7
11
+ waitForInputStart: "waitForInputStart",
12
+ pieceClickedThreshold: "pieceClickedThreshold",
13
+ clickTo: "clickTo",
14
+ secondClickThreshold: "secondClickThreshold",
15
+ dragTo: "dragTo",
16
+ clickDragTo: "clickDragTo",
17
+ moveDone: "moveDone",
18
+ reset: "reset"
19
19
  }
20
20
 
21
21
  export const MOVE_CANCELED_REASON = {
@@ -41,7 +41,8 @@ export class VisualMoveInput {
41
41
  if (result) {
42
42
  this.chessboard.state.moveInputProcess = Utils.createTask()
43
43
  this.chessboard.state.moveInputProcess.then((result) => {
44
- if(this.moveInputState === MOVE_INPUT_STATE.waitForInputStart) {
44
+ if (this.moveInputState === MOVE_INPUT_STATE.waitForInputStart ||
45
+ this.moveInputState === MOVE_INPUT_STATE.moveDone) {
45
46
  view.moveInputFinishedCallback(this.fromSquare, this.toSquare, result)
46
47
  }
47
48
  })
@@ -109,7 +110,7 @@ export class VisualMoveInput {
109
110
  } else {
110
111
  throw Error("4b74af")
111
112
  }
112
- if(!this.contextMenuListener) {
113
+ if (!this.contextMenuListener) {
113
114
  this.contextMenuListener = this.onContextMenu.bind(this)
114
115
  this.chessboard.view.svg.addEventListener("contextmenu", this.contextMenuListener)
115
116
  }
@@ -323,7 +324,10 @@ export class VisualMoveInput {
323
324
  if (this.moveInputState === MOVE_INPUT_STATE.pieceClickedThreshold || this.moveInputState === MOVE_INPUT_STATE.secondClickThreshold) {
324
325
  if (Math.abs(this.startPoint.x - clientX) > DRAG_THRESHOLD || Math.abs(this.startPoint.y - clientY) > DRAG_THRESHOLD) {
325
326
  if (this.moveInputState === MOVE_INPUT_STATE.secondClickThreshold) {
326
- this.setMoveInputState(MOVE_INPUT_STATE.clickDragTo, {square: this.fromSquare, piece: this.movedPiece})
327
+ this.setMoveInputState(MOVE_INPUT_STATE.clickDragTo, {
328
+ square: this.fromSquare,
329
+ piece: this.movedPiece
330
+ })
327
331
  } else {
328
332
  this.setMoveInputState(MOVE_INPUT_STATE.dragTo, {square: this.fromSquare, piece: this.movedPiece})
329
333
  }