frontend: delay fullpage init after post fetch
Signed-off-by: Nicolas Froger <nicolas@kektus.xyz>
This commit is contained in:
parent
4d5165473b
commit
90163b5db5
2 changed files with 16 additions and 5 deletions
|
|
@ -11,7 +11,7 @@ export const usePostsStore = defineStore('posts', () => {
|
||||||
const posts = ref([])
|
const posts = ref([])
|
||||||
|
|
||||||
function fetchPosts() {
|
function fetchPosts() {
|
||||||
fetch(postsApiPath)
|
return fetch(postsApiPath)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
return response.json()
|
return response.json()
|
||||||
})
|
})
|
||||||
|
|
@ -28,7 +28,5 @@ export const usePostsStore = defineStore('posts', () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchPosts()
|
return { posts, fetchPosts }
|
||||||
|
|
||||||
return { posts }
|
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import PostComponent from '@/components/PostComponent.vue'
|
import PostComponent from '@/components/PostComponent.vue'
|
||||||
import { usePostsStore } from '@/stores/posts.js'
|
import { usePostsStore } from '@/stores/posts.js'
|
||||||
import { ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import WelcomeComponent from '@/components/WelcomeComponent.vue'
|
import WelcomeComponent from '@/components/WelcomeComponent.vue'
|
||||||
|
|
||||||
const postsStore = usePostsStore()
|
const postsStore = usePostsStore()
|
||||||
|
|
@ -18,6 +18,18 @@ const fullpageOptions = ref({
|
||||||
credits: { enabled: false }
|
credits: { enabled: false }
|
||||||
})
|
})
|
||||||
const menu = ref(null)
|
const menu = ref(null)
|
||||||
|
let fullPageInit = false;
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
postsStore.fetchPosts().then(() => {
|
||||||
|
if (!fullPageInit) {
|
||||||
|
fullpage.value.init();
|
||||||
|
fullPageInit = true;
|
||||||
|
} else {
|
||||||
|
fullpage.value.build();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
function onLeave(origin, destination, direction, trigger) {
|
function onLeave(origin, destination, direction, trigger) {
|
||||||
if (destination.anchor === 'welcome-section') {
|
if (destination.anchor === 'welcome-section') {
|
||||||
|
|
@ -55,6 +67,7 @@ function afterLoad(origin, destination, direction, trigger) {
|
||||||
:options="fullpageOptions"
|
:options="fullpageOptions"
|
||||||
@on-leave="onLeave"
|
@on-leave="onLeave"
|
||||||
@after-load="afterLoad"
|
@after-load="afterLoad"
|
||||||
|
:skip-init="true"
|
||||||
>
|
>
|
||||||
<WelcomeComponent />
|
<WelcomeComponent />
|
||||||
<PostComponent class="section" v-for="post in postsStore.posts" :key="post.id" :post="post" />
|
<PostComponent class="section" v-for="post in postsStore.posts" :key="post.id" :post="post" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue