elk/components/common/CommonScrollIntoView.vue
Joaquín Sánchez 9da77637b2
chore: bump to eslint-config v2.8.0 (#2651)
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
2024-03-05 14:48:58 +00:00

21 lines
368 B
Vue

<script setup lang="ts">
const { as = 'div', active } = defineProps<{
as: any
active: boolean
}>()
const el = ref()
watch(() => active, (active) => {
const _el = unrefElement(el)
if (active && _el)
_el.scrollIntoView({ block: 'nearest', inline: 'start' })
})
</script>
<template>
<component :is="as" ref="el">
<slot />
</component>
</template>