How to use the chessground/chessground function in chessground

To help you get started, we’ve selected a few chessground examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ornicar / chessground / examples / src / play.ts View on Github external
run(el) {
    const chess = new Chess();
    const cg = chessground(el, {
      movable: {
        color: 'white',
        free: false,
        dests: toDests(chess)
      }
    });
    cg.set({
      // draggable: {
      //   showGhost: false
      // },
      movable: {
        events: {
          after(orig, dest) {
            chess.move({from: orig, to: dest});
            cg.set({
              turnColor: toColor(chess),
github ornicar / chessground / examples / src / perf.ts View on Github external
run(cont) {
    const cg = chessground(cont, {
      movable: {
        free: false,
        dests: {
          e2: ['e3', 'e4', 'd3', 'f3']
        }
      }
    });
    const el = cont.querySelector('.cg-board') as HTMLElement;
    const delay = 500;
    function run() {
      if (!el.offsetParent) return;
      cg.selectSquare('e2');
      setTimeout(() => {
        cg.selectSquare('d4');
        setTimeout(run, delay);
      }, delay);
github ornicar / chessground / examples / src / perf.ts View on Github external
run(cont) {
    const cg = chessground(cont, {
      animation: { duration: 500 }
    });
    const el = cont.querySelector('.cg-board') as HTMLElement;
    const delay = 400;
    function run() {
      if (!el.offsetParent) return;
      cg.move('e2', 'd4');
      setTimeout(() => {
        cg.move('d4', 'e2');
        setTimeout(run, delay);
      }, delay);
    }
    setTimeout(run, delay);
    return cg;
  }
};

chessground

lichess.org chess ui

GPL-3.0
Latest version published 3 days ago

Package Health Score

81 / 100
Full package analysis