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

Arrows sometimes display wrong #124

Closed blasco closed 10 months ago

blasco commented 12 months ago

I've updated to the latest version. I'm now using the assetsPath, as suggested:

    const config = {
      assetsUrl: 'assets/cm-chessboard/',
      extensions: [
        { class: Markers },
        { class: Arrows },
      ],
      responsive: true,
    };
    this.chessboard = new Chessboard(this.chessboardElement, config);

Everything seems to be working fine, but sometimes arrows display wrong:

image

And I'm getting these errors:

Error: <marker> attribute markerWidth: Expected length, "undefined".
Error: <marker> attribute markerHeight: Expected length, "undefined".

What could be going on?

blasco commented 12 months ago

I was setting the structure of the assets wrong, now it seems to work fine. Never the less, I still get that error every time I get to draw an arrow:

image

actor10 commented 12 months ago

What are you passing to "addArrow()"?

No error if you don't draw an arrow?

blasco commented 12 months ago

Hi, I'm passing this:

  public addArrow(arrow: {
    type: typeof ARROW_TYPE;
    from: string;
    to: string;
  }) {
    try {
      this.chessboard.addArrow(arrow.type, arrow.from, arrow.to);
    } catch (error) {
      console.warn('Error adding arrow:', error);
    }
  }

An ARROW_TYPE, a from and and a to

shaack commented 12 months ago

I am not sure, but it looks like your arrow has no headSize set. There is a working example online under this URL: https://shaack.com/projekte/cm-chessboard/examples/extensions/arrows-extension.html