Info on the right bottom corner
Target Element (scroll down)
Element outside the viewport

useElementVisibility

Tracks the visibility of an element within the viewport.

Usage

<template>
  <div ref="target">
    <h1>Hello world</h1>
  </div>
</template>

<script>
import { ref } from 'vue'
import { useElementVisibility } from '@vueuse/core'

export default {
  setup() {
    const target = ref(null)
    const targetIsVisible = useElementVisibility(target)

    return {
      target,
      targetIsVisible,
    }
  }
}
</script>

Type Declarations

export interface VisibilityScrollTargetOptions extends ConfigurableWindow {
  scrollTarget?: Ref<Element | null | undefined>
}
/**
 * Tracks the visibility of an element within the viewport.
 *
 * @see   {@link /useElementVisibility}
 * @param element
 * @param options
 */
export declare function useElementVisibility(
  element: Ref<Element | null | undefined>,
  { window, scrollTarget }?: VisibilityScrollTargetOptions
): Ref<boolean>

Source

SourceDemoDocs