I have a carousel which only shows when a user opens my accordion menu.
I am using v-show to hide the carousel until it's opened. However, it doesn't render the carousel correctly unless I resize the browser window, the first slide shows but to click through the other slides don't show up.
Web inspect shows on load the translate: transform() empty for slides until the browser window is resized.
I think this is something to do with v-show and how it renders in the DOM, I have seen people using .$nextTick or .$watch to fix similar issues but I don't understand them enough to apply them to my code.
Is there a way for me to solve this issue using v-show with .nextTick() or .watch()?
<div :key="project.id">
<!-- project header -->
<li
class="project accordion columns is-flex vcenter"
@click="toggleItem"
style="margin-left: 0; margin-right: 0;"
>
<h3 class="project-title column is-one-quarter">{{ project.Name }}</h3>
<h4 class="project-summary column is-two-thirds">
{{ project.Summary }}
</h4>
<span class="column is-one-half is-gapless project-icon">
<img
src="../static/SVG/Circle.svg"
alt="circle icon for branding & identity"
/>
</span>
</li>
My hidden content is here, it only shows when the accordion is open using v-show.
<div class="showcase-content columns" v-show="show">
<p class="project-description column is-one-third">
{{ project.Description }}
</p>
<agile :fade="true">
<div
class="image-box column is-two-thirds"
v-for="image in project.image"
:key="image.url"
>
<img :src="buildImageUrl(image.url)" alt="" />
</div>
</agile>
</div>
EDIT I was originally injecting some my accordion in and have refactored the accordion and my code, on the suspicion that injection might not be reactive but the same issue persists. The code on this question is my current code.
<script>
export default {
name: 'ProjectItem',
data: function () {
return {
show: false,
}
},
props: ['project'],
methods: {
toggleItem: function () {
this.show = !this.show
},
buildImageUrl(image) {
if (!image) return '../static/images/SamB.png'
return `http://localhost:1337${image}`
},
},
}
</script>