Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange formatting with small boards #15

Open
jacksonthall22 opened this issue Jul 11, 2024 · 0 comments
Open

Strange formatting with small boards #15

jacksonthall22 opened this issue Jul 11, 2024 · 0 comments

Comments

@jacksonthall22
Copy link

jacksonthall22 commented Jul 11, 2024

This is a strange one - I am trying to include a small diagram on my site and the position of both the piece and board sizes seems to be off:

image

However, when I toggle the orientation by calling cg.set({ orientation: 'black' }) on the instance bound to this on the component, the problem seems to go away (see below - the cg-board still does not fill the full height/width of the cg-wrap element, but not sure if this might be intended behavior). It does not fix itself if I update other config options, ex. cg.set({ fen: '...' }).

image

This led me to think that as a workaround, I could just wait for the component to be mounted by subscribing to the cg element bound to this on the component (to see when it becomes not undefined), then toggle the orientation twice, but that doesn't work either (this one really confuses me):

<script>
  //...

  let cg: Chessground
  let myConfig: Config = {
    // I set nearly every option explicitly here
  }

  $: if (cg !== undefined) {
    const currentOrientation = cg.getState().orientation;
    cg.set({
      ...previewGame.cgConfig,
      orientation: originalOrientation === 'white' ? 'black': 'white',
    })
  }
</script>

<div>
<Chessground bind:this={cg} config={ />

I tried looking into the code a bit to see what's going on in set(), but I don't quite understand it. Happy to provide more info to help resolve it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant