Skip to content

Commit 15a9f1e

Browse files
committed
fix(loading): add minimum height to settings loader
1 parent 5e72b36 commit 15a9f1e

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/components/common/loading/PageLoading.vue

+14-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@
22
import { NIcon } from 'naive-ui';
33
44
import IconLoadingMatrix from '~/components/icons/IconLoadingMatrix.vue';
5+
6+
defineProps({
7+
size: {
8+
type: String,
9+
required: false,
10+
default: '3rem',
11+
},
12+
minHeight: {
13+
type: String,
14+
required: false,
15+
},
16+
});
517
</script>
618

719
<template>
8-
<NIcon class="loading-container" size="3rem">
20+
<NIcon class="loading-container" :style="{ '--min-height': minHeight }" :size="size">
921
<IconLoadingMatrix />
1022
</NIcon>
1123
</template>
@@ -19,6 +31,7 @@ import IconLoadingMatrix from '~/components/icons/IconLoadingMatrix.vue';
1931
justify-content: center;
2032
width: 100%;
2133
height: 100%;
34+
min-height: var(--min-height, 0);
2235
padding-bottom: layout.$header-navbar-height;
2336
opacity: 1;
2437
transition: opacity 1s ease-in 0.2s;

src/components/views/settings/SettingsComponent.vue

+5-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ onDeactivated(() => {
145145
:ref="section.reference"
146146
class="card"
147147
:class="{ target: focus?.title === section.title }"
148-
:style="{ '--length': sections.length, '--index': index }"
148+
:style="{
149+
'--length': sections.length,
150+
'--index': index,
151+
}"
149152
:title="i18n(section.title)"
150153
@mouseenter="onEnter(section)"
151154
@mouseleave="onLeave(section)"
@@ -155,7 +158,7 @@ onDeactivated(() => {
155158
<Suspense>
156159
<component :is="section.component" />
157160
<template #fallback>
158-
<PageLoading />
161+
<PageLoading min-height="var(--height-40-dvh)" />
159162
</template>
160163
</Suspense>
161164
</NCard>

src/utils/calendar.utils.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,14 @@ export const useCalendar = ({
134134
list,
135135
centerItem,
136136
fetchData,
137+
itemSize = 145,
138+
placeholders = 1,
137139
}: {
138140
list: Ref<ListScrollItem[]>;
139141
centerItem: Ref<ListScrollItem | undefined>;
140142
fetchData: (mode?: 'start' | 'end' | 'reload') => Promise<unknown>;
143+
itemSize?: number;
144+
placeholders?: number;
141145
}) => {
142146
const listRef = ref<{ list: VirtualListRef }>();
143147
const scrollTo = (options?: VirtualListScrollToOptions, index = centerItem.value?.index) => {
@@ -169,14 +173,14 @@ export const useCalendar = ({
169173
let placeholder = 0;
170174
const timeout = setTimeout(() => {
171175
listRef.value?.list.scrollTo({ top: 145 });
172-
placeholder = 1;
176+
placeholder = placeholders;
173177
}, defaultDebounceLoadingDelay); // default debounceLoading delay
174178

175179
await fetching;
176180

177181
clearTimeout(timeout);
178182
listRef.value?.list.scrollTo({
179-
top: (list.value.findIndex(item => item.id === first.id) - placeholder) * 145,
183+
top: (list.value.findIndex(item => item.id === first.id) - placeholder) * itemSize,
180184
});
181185
placeholder = 0;
182186
};

0 commit comments

Comments
 (0)