salix-front/src/components/LeftMenuItemGroup.vue

41 lines
934 B
Vue
Raw Normal View History

2022-11-29 13:45:48 +00:00
<script setup>
2024-02-27 13:55:45 +00:00
import { computed, ref, defineExpose } from 'vue';
2022-11-29 13:45:48 +00:00
import LeftMenuItem from './LeftMenuItem.vue';
2024-02-27 13:55:45 +00:00
import { elementIsVisibleInViewport } from 'src/composables/elementIsVisibleInViewport';
2022-11-29 13:45:48 +00:00
const props = defineProps({
item: {
type: Object,
required: true,
},
group: {
type: String,
default: '',
},
});
2024-02-27 13:55:45 +00:00
const groupEnd = ref(null);
const scrollToLastElement = () => {
if (groupEnd.value && !elementIsVisibleInViewport(groupEnd.value)) {
groupEnd.value.scrollIntoView({
behavior: 'smooth',
block: 'end',
});
}
};
2023-05-26 12:01:24 +00:00
const item = computed(() => props.item); // eslint-disable-line vue/no-dupe-keys
2024-02-27 13:55:45 +00:00
defineExpose({
scrollToLastElement,
});
2022-11-29 13:45:48 +00:00
</script>
2024-02-27 13:55:45 +00:00
2022-11-29 13:45:48 +00:00
<template>
2023-08-09 11:29:00 +00:00
<template v-for="section in item.children" :key="section.name">
<LeftMenuItem :item="section" />
</template>
2024-02-27 13:55:45 +00:00
<div ref="groupEnd" />
2022-11-29 13:45:48 +00:00
</template>