vue-chessboard
vue-chessboard copied to clipboard
How i can disable user moves?
Hi, i need disable user moves feature. I need only programmatically moves.
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>
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 = ''; },