shaack / cm-chessboard

A JavaScript chessboard without dependencies. Rendered in SVG, coded in ES6. Views FEN, handles move input, animated, responsive, expandable
MIT License
209 stars 63 forks source link

chessboard.removeMarkers(type) does not seem to be working? #93

Closed vesper8 closed 1 year ago

vesper8 commented 1 year ago

Using cm-chessboard@5.3.3

I have this code


export const CONSOLE_MARKER_TYPE = {
  moveToMarker: {class: "markerFrame", slice: "markerFrame"},
  moveFromMarker: {class: "markerFrame", slice: "markerFrame"},
  lastMove: {class: "markerFrame", slice: "markerFrame"},
  check: {class: "markerCircleRed", slice: "markerCircle"},
  wrongMove: {class: "markerFrameRed", slice: "markerFrame"},
  premove: {class: "markerFramePremove", slice: "markerFrame"},
}

    markLastMove(squareFrom, squareTo) {
      window.clearTimeout(this.markLastMoveDebounce);
      this.markLastMoveDebounce = setTimeout(() => {
        this.chessboard.removeMarkers(CONSOLE_MARKER_TYPE.lastMove);
        if (squareFrom && squareTo) {
          this.chessboard.addMarker(CONSOLE_MARKER_TYPE.lastMove, squareFrom);
          this.chessboard.addMarker(CONSOLE_MARKER_TYPE.lastMove, squareTo);
        }
      });
    },

It correctly adds the markers, but then it doesn't remove them.

The line this.chessboard.removeMarkers(CONSOLE_MARKER_TYPE.lastMove); just does nothing.

It works if I remove the type: this.chessboard.removeMarkers();

Am I doing something wrong?

shaack commented 1 year ago

It should work, just try the "Remove all dots" Button in this example: https://shaack.com/projekte/cm-chessboard/examples/input-callbacks.html

djeetee commented 1 year ago

The above link doesn't seem to go anywhere.

shaack commented 1 year ago

It was moved to here: https://shaack.com/projekte/cm-chessboard/examples/extensions/markers-extension.html

djeetee commented 1 year ago

Thanks Stefan. I have that. I thought it was for another version or a new page.