1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-24 06:28:42 +01:00

Cleans up define props with typescript and cleans up css (#1879)

* Tries to clean up defineprops

* Cleans up define props for all components
This commit is contained in:
Amir Raminfar
2022-09-14 12:00:36 -07:00
committed by GitHub
parent cc8a7ee8e7
commit 70d72060d9
13 changed files with 76 additions and 105 deletions

View File

@@ -9,21 +9,21 @@
</template>
<script lang="ts" setup>
const props = defineProps({
onLoadMore: Function,
enabled: Boolean,
});
const { onLoadMore = () => {}, enabled } = defineProps<{
onLoadMore: () => void;
enabled: boolean;
}>();
const isLoading = ref(false);
const root = ref<HTMLElement>();
const observer = new IntersectionObserver(async (entries) => {
if (entries[0].intersectionRatio <= 0) return;
if (props.onLoadMore && props.enabled) {
if (onLoadMore && enabled) {
const scrollingParent = root.value?.closest("[data-scrolling]") || document.documentElement;
const previousHeight = scrollingParent.scrollHeight;
isLoading.value = true;
await props.onLoadMore();
await onLoadMore();
isLoading.value = false;
await nextTick();
scrollingParent.scrollTop += scrollingParent.scrollHeight - previousHeight;