diff --git a/dashboard/src/views/AppstoreView.vue b/dashboard/src/views/AppstoreView.vue index dda154ed5..4b22f3703 100644 --- a/dashboard/src/views/AppstoreView.vue +++ b/dashboard/src/views/AppstoreView.vue @@ -165,6 +165,19 @@ async function onHashChange() { } } +const view = useTemplateRef('view'); +const itemWidth = ref('unset'); + +function setItemWidth() { + const width = view.value.offsetWidth; + const gap = 20; // flexbox gap value + + if (width <= 575) itemWidth.value = '100%'; + else if (width <= 800) itemWidth.value = Number((width-gap*2)/2).toFixed() + 'px'; + else if (width <= 1024) itemWidth.value = Number((width-gap*3)/3).toFixed() + 'px'; + else itemWidth.value = Number((width-gap*4)/4).toFixed() + 'px'; +} + onMounted(async () => { await getInstalledApps(); await getAppList(); @@ -173,16 +186,21 @@ onMounted(async () => { // only deals with #/appstore/ hashes window.addEventListener('hashchange', onHashChange); onHashChange(); + + window.addEventListener('resize', setItemWidth); + + setItemWidth(); }); onUnmounted(() => { window.removeEventListener('hashchange', onHashChange); + window.removeEventListener('resize', setItemWidth); });