vue-chessboard icon indicating copy to clipboard operation
vue-chessboard copied to clipboard

How i can disable user moves?

Open facku opened this issue 4 years ago • 2 comments

Hi, i need disable user moves feature. I need only programmatically moves.

facku avatar Aug 16 '20 17:08 facku

Probably I will add that option in a future version (maybe next month), for now I think you can create a new component that extend vue-chessboard (https://github.com/vitogit/vue-chessboard#extended-component-play-vs-random-ai) and use the chessground viewonly option.

  <script>
  import { chessboard }  from 'vue-chessboard'

  export default {
    name: 'newboard',
    extends: chessboard,
    mounted() {
      this.board.set({
        viewOnly: true
      })
    }
  }
  </script>

vitogit avatar Aug 17 '20 15:08 vitogit

I do this using a method that sets the state.movable.color attribute. It has the drawback of no longer allowing the user to scroll the page when pressing on the board though when run on a touch enabled device.

setBoardUnmovable: function() { this.$refs.echessboard.board.state.movable.color = ''; },

jlincoln avatar Apr 01 '21 16:04 jlincoln