I am facing a challenge in rendering a new element once the boolean variable waiting
changes to true. The issue arises when transitioning from one v-if
statement to another, as the boolean does not update until the first statement is completed. How can I smoothly transition to the second v-if
condition after the first one is fulfilled without placing the code directly below due to input dependency?
Considering redirecting to a different page as a solution, but I prefer keeping all variables consolidated in one place.
<template>
<transition name="fade">
<div class="home" v-if="!secondplayer">
<div class="inner">
<img class="responsive" src="/static/mask.png" alt="Responsive image" />
<h1>How well do you understand the lyrics in Hamilton?</h1>
<br />
<p>Invite a second player by sending them this link: <u>{{url}}</u>.</p>
</div>
</div>
<div class="play" v-if="secondplayer">
<div v-if="!waiting">
<div class="container hamilton--header--text">
<h1><i>Test your understanding of Hamilton lyrics</i></h1>
<div class="columns hamilton--inner">
<div class="column is-half left">
<p class="title">Player 1</p>
<p class="subtitle">Score: {{playerdata.one.score}}</p>
</div>
<div v-if="secondplayer" class="column is-half right">
<p class="title">Player 2</p>
<p class="subtitle">Score: {{playerdata.two.score}}</p>
</div>
</div>
<div class="hamilton--lyrics--text">
<p>{{question.lyric}}
</p>
<div class="hamilton--answers">
<a v-bind:class="{ 'wronganswer': hasAnswered && !item.correct, 'correctanswer': hasAnswered && item.correct}" @click="checkAnswer(item)" v-for="(item, index) in options">{{item.name}}</a>
</div>
</div>
</div>
</div>
<div v-if="waiting">
<div class="container">
<h1>Waiting for the other player to finish...</h1>
<img src="/static/Spinner.gif">
</div>
</div>
</div>
<div class="gameOver" v-if="winMessage">
<div>
<div class="container">
<h1>{{winMessage}}</h1>
<vue-simple-spinner size="big" message="Loading..."></vue-simple-spinner>
</div>
</div>
</div>
</transition>
</template>