Rearranging the slides
We can add the required methods
for the SliderPuzzle.vue
component by writing the following code:
<script> ... export default { ... methods: { swap(index) { if (!this.timer) { return; } if (this.indexesToSwap.length < 2) { this.indexesToSwap.push(index); } if (this.indexesToSwap.length === 2) { ... this.resetTime(); clearInterval(this.timer); }, resetTime() { this.startDateTime = new Date(); this.currentDateTime = new Date(); ...