2024-11-18 18:26:28 +02:00
|
|
|
<template>
|
|
|
|
|
<section :class="{ 'active-section': isActive }" ref="section">
|
|
|
|
|
<slot />
|
|
|
|
|
</section>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { watch, useTemplateRef } from 'vue'
|
|
|
|
|
|
2024-11-20 09:48:18 +02:00
|
|
|
const props = defineProps<{ isActive: boolean; isNextActiveSection: boolean }>()
|
2024-11-18 18:26:28 +02:00
|
|
|
|
|
|
|
|
const sectionRef = useTemplateRef('section')
|
|
|
|
|
|
|
|
|
|
// плавная прокрутка при активации секции
|
|
|
|
|
watch(
|
2024-11-20 11:26:28 +02:00
|
|
|
() => sectionRef.value && props.isNextActiveSection,
|
2024-11-20 09:48:18 +02:00
|
|
|
(isNextActiveSection) => {
|
|
|
|
|
if (isNextActiveSection) {
|
2024-11-21 08:46:06 +02:00
|
|
|
const input = sectionRef.value?.querySelector('input[type="text"]')
|
|
|
|
|
if (input instanceof HTMLInputElement) {
|
|
|
|
|
input.focus()
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-18 18:26:28 +02:00
|
|
|
sectionRef.value?.scrollIntoView({ behavior: 'smooth' })
|
|
|
|
|
}
|
|
|
|
|
},
|
2024-11-20 11:26:28 +02:00
|
|
|
{ immediate: true },
|
2024-11-18 18:26:28 +02:00
|
|
|
)
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
section {
|
|
|
|
|
opacity: 0.1;
|
|
|
|
|
transition: opacity 0.5s;
|
|
|
|
|
pointer-events: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
section {
|
|
|
|
|
border-top: 1px solid silver;
|
|
|
|
|
padding-top: 1em;
|
|
|
|
|
}
|
|
|
|
|
section:first-of-type {
|
|
|
|
|
border-top: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
section.active-section {
|
|
|
|
|
opacity: 1;
|
|
|
|
|
pointer-events: all;
|
|
|
|
|
}
|
|
|
|
|
</style>
|