diff --git a/components/expDiagram.vue b/components/expDiagram.vue index 0f81605..fb49694 100644 --- a/components/expDiagram.vue +++ b/components/expDiagram.vue @@ -9,15 +9,33 @@ const controlsState = reactive({ enableZoom: false, maxPolarAngle: (Math.PI / 2) - 0.2, }) - +const container = ref() +const koef = ref() +const scrollBlock = (e: Event) => { + const { top, bottom, height } = container.value.getBoundingClientRect(); + const { innerHeight } = window; + const partiallyVisible = (top > 0 && top < innerHeight) || + (bottom > 0 && bottom < innerHeight) + const visibleHeight = innerHeight - top + const h = height * 1.5 + if (partiallyVisible && visibleHeight < h) { + koef.value = visibleHeight / h + } +} +onMounted(() => { + document.addEventListener('scroll', scrollBlock) +}) +onUnmounted(() => { + document.removeEventListener('scroll', scrollBlock) +})