mirror of
https://github.com/elk-zone/elk.git
synced 2024-09-06 20:29:08 +01:00
18 lines
364 B
Vue
18 lines
364 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>
|