cm-chessboard 7.6.2 → 7.6.3

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.
@@ -47,7 +47,7 @@ function inputHandler(event) {
47
47
  <script type="module">
48
48
  import {INPUT_EVENT_TYPE, Chessboard} from "../src/Chessboard.js"
49
49
  import {FEN} from "../src/model/Position.js"
50
- import {MARKER_TYPE, Markers} from "../src/extensions/markers/Markers.js"
50
+ import {Markers} from "../src/extensions/markers/Markers.js"
51
51
 
52
52
  window.board = new Chessboard(document.getElementById("board"), {
53
53
  position: FEN.start,
@@ -59,8 +59,7 @@ function inputHandler(event) {
59
59
  window.board.enableMoveInput(inputHandler)
60
60
 
61
61
  function inputHandler(event) {
62
- console.log(event)
63
- window.board.removeMarkers(MARKER_TYPE.frame)
62
+ // console.log(event)
64
63
  switch (event.type) {
65
64
  case INPUT_EVENT_TYPE.moveInputStarted:
66
65
  log(`moveInputStarted: ${event.square}`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "7.6.2",
3
+ "version": "7.6.3",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",
@@ -31,7 +31,6 @@ export class Markers extends Extension {
31
31
  sprite: "markers.svg" // the sprite file of the markers
32
32
  }
33
33
  Object.assign(this.props, props)
34
- this.autoMarker = {}
35
34
  if (chessboard.props.assetsCache) {
36
35
  chessboard.view.cacheSpriteToDiv("cm-chessboard-markers", this.chessboard.props.assetsUrl +
37
36
  "extensions/markers/" + this.props.sprite)
@@ -43,7 +42,7 @@ export class Markers extends Extension {
43
42
  this.markerGroupUp = Svg.addElement(chessboard.view.markersTopLayer, "g", {class: "markers"})
44
43
  this.markers = []
45
44
  if (this.props.autoMarkers) {
46
- Object.assign(this.autoMarker, this.props.autoMarkers)
45
+ Object.assign(this.props.autoMarkers, this.props.autoMarkers)
47
46
  this.registerExtensionPoint(EXTENSION_POINT.moveInput, (event) => {
48
47
  this.drawAutoMarkers(event)
49
48
  })
@@ -51,7 +50,9 @@ export class Markers extends Extension {
51
50
  }
52
51
 
53
52
  drawAutoMarkers(event) {
54
- this.removeMarkers(this.autoMarker)
53
+ if(event.type !== INPUT_EVENT_TYPE.moveInputFinished) {
54
+ this.removeMarkers(this.props.autoMarkers)
55
+ }
55
56
  if (event.type === INPUT_EVENT_TYPE.moveInputStarted &&
56
57
  !event.moveInputCallbackResult) {
57
58
  return
@@ -59,10 +60,10 @@ export class Markers extends Extension {
59
60
  if (event.type === INPUT_EVENT_TYPE.moveInputStarted ||
60
61
  event.type === INPUT_EVENT_TYPE.movingOverSquare) {
61
62
  if (event.squareFrom) {
62
- this.addMarker(this.autoMarker, event.squareFrom)
63
+ this.addMarker(this.props.autoMarkers, event.squareFrom)
63
64
  }
64
65
  if (event.squareTo) {
65
- this.addMarker(this.autoMarker, event.squareTo)
66
+ this.addMarker(this.props.autoMarkers, event.squareTo)
66
67
  }
67
68
  }
68
69
  }