Skip to content

Commit c24c8ac

Browse files
committed
fix(loading): only offset placeholder if passed timeout
1 parent 655c164 commit c24c8ac

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/utils/calendar.utils.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,20 @@ export const useCalendar = ({
165165
const first = list.value[0];
166166
const fetching = fetchData('start');
167167

168+
// offset the scroll by 1 item if a placeholder is added
169+
let placeholder = 0;
168170
const timeout = setTimeout(() => {
169171
listRef.value?.list.scrollTo({ top: 145 });
172+
placeholder = 1;
170173
}, defaultDebounceLoadingDelay); // default debounceLoading delay
171174

172175
await fetching;
173176

174177
clearTimeout(timeout);
175178
listRef.value?.list.scrollTo({
176-
top: list.value.findIndex(item => item.id === first.id) * 145,
179+
top: (list.value.findIndex(item => item.id === first.id) - placeholder) * 145,
177180
});
181+
placeholder = 0;
178182
};
179183

180184
const onScrollBottom = async () => {

0 commit comments

Comments
 (0)