VIntersect

Uses IntersectionObserver to fire events when content enters or exits the screen.

Open your console and scroll around to watch events get fired.

<template>
  <div>
    <VIntersect
      @enter="log('@enter fired for block 1')"
      @exit="log('@exit fired for block 1')"
      @change="log('@change fired for block 1')"
    >
      <div class="intersection-content">Content block 1</div>
    </VIntersect>

    <VIntersect
      @enter="log('@enter fired for block 2')"
      @exit="log('@exit fired for block 2')"
      @change="log('@change fired for block 2')"
    >
      <div class="intersection-content">Content block 2</div>
    </VIntersect>

    <VIntersect
      @enter="log('@enter fired for block 3')"
      @exit="log('@exit fired for block 3')"
      @change="log('@change fired for block 3')"
    >
      <div class="intersection-content">Content block 3</div>
    </VIntersect>
  </div>
</template>

<script>
export default {
  methods: {
    log: console.log,
  },
}
</script>
.intersection-content {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50vh;
  border: 1px solid;
}
Last Updated: 9/7/2019, 6:20:02 PM