mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-04-09 22:45:36 -04:00
feat: Added scroll to top on all pages that have recipeCardSection (#7384)
This commit is contained in:
committed by
GitHub
parent
4ee97e5348
commit
bb278aac35
@@ -167,6 +167,7 @@
|
|||||||
:loading="loading"
|
:loading="loading"
|
||||||
/>
|
/>
|
||||||
</v-fade-transition>
|
</v-fade-transition>
|
||||||
|
<AppScrollToTop />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
38
frontend/components/Layout/LayoutParts/AppScrollToTop.vue
Normal file
38
frontend/components/Layout/LayoutParts/AppScrollToTop.vue
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<template>
|
||||||
|
<v-fade-transition>
|
||||||
|
<v-btn
|
||||||
|
v-if="showButton"
|
||||||
|
icon
|
||||||
|
position="fixed"
|
||||||
|
location="bottom right"
|
||||||
|
class="ma-4"
|
||||||
|
color="primary"
|
||||||
|
elevation="4"
|
||||||
|
style="z-index: 999;"
|
||||||
|
@click="scrollToTop"
|
||||||
|
>
|
||||||
|
<v-icon>{{ $globals.icons.arrowUp }}</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</v-fade-transition>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const showButton = ref(false);
|
||||||
|
const threshold = 400;
|
||||||
|
|
||||||
|
function onScroll() {
|
||||||
|
showButton.value = document.documentElement.scrollTop > threshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
function scrollToTop() {
|
||||||
|
document.documentElement.scrollTop = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
window.addEventListener("scroll", onScroll);
|
||||||
|
});
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
window.removeEventListener("scroll", onScroll);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
mdiArrowLeftBoldOutline,
|
mdiArrowLeftBoldOutline,
|
||||||
mdiArrowRightBold,
|
mdiArrowRightBold,
|
||||||
mdiArrowRightBoldOutline,
|
mdiArrowRightBoldOutline,
|
||||||
|
mdiArrowUp,
|
||||||
mdiBackupRestore,
|
mdiBackupRestore,
|
||||||
mdiBeakerOutline,
|
mdiBeakerOutline,
|
||||||
mdiBellAlert,
|
mdiBellAlert,
|
||||||
@@ -177,6 +178,7 @@ export const icons = {
|
|||||||
api: mdiApi,
|
api: mdiApi,
|
||||||
arrowLeftBold: mdiArrowLeftBold,
|
arrowLeftBold: mdiArrowLeftBold,
|
||||||
arrowRightBold: mdiArrowRightBold,
|
arrowRightBold: mdiArrowRightBold,
|
||||||
|
arrowUp: mdiArrowUp,
|
||||||
arrowUpDown: mdiDrag,
|
arrowUpDown: mdiDrag,
|
||||||
backupRestore: mdiBackupRestore,
|
backupRestore: mdiBackupRestore,
|
||||||
bellAlert: mdiBellAlert,
|
bellAlert: mdiBellAlert,
|
||||||
|
|||||||
Reference in New Issue
Block a user