# VIntersect

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

Source

# Installation

Globally:

// main.js
import Vue from "vue"
import { VIntersect } from "vuetensils"

Vue.component("VIntersect", VIntersect)

Locally:

<script>
// SomeComponent.vue
import { VIntersect } from "vuetensils"

export default {
  components: {
    VIntersect,
  },
  // ...
}
</script>

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: 11/19/2019, 5:58:27 AM