You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

vue-intersect

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-intersect

A Vue component to add intersection-observer to a Vue component or HTML element.

1.0.2
Source
npmnpm
Version published
Weekly downloads
3K
-27.29%
Maintainers
1
Weekly downloads
 
Created
Source

Vue Intersect

A Vue component to add intersection observe a Vue component or HTML element.

npm version

Table of content

Introduction

The IntersectionObserver is an amazing API which allows you to observe one or more HTMLElement for when it has enterede or left the viewport.

This API has many use cases like, infinite-scroll, lazy-loading or animations when an element enters the viewport.

Installation

Simply install using your favorite package manager 🔥

NPM

npm install vue-intersect --save

Yarn

yarn add vue-intersect

Usage

The package acts as an abstract component, much like what you may know from keep-alive or transition.

This means that it's basically a "decorator". A component which does not output any markup to the DOM, but adds the functionality under the hood 😱.

.vue

<template>
  <intersect @intersected="msg = 'Intersected!'">
    <div>{{ msg }}</div>
  </intersect>
</template>

<script>
  import Intersect from 'vue-intersect'

  export default {
    components: { Intersect },
    data () {
      return {
        msg: 'Not intersected.'
      }
    },
    methods: {
      onIntersected () {
        alert('Element has intersected.')
      }
    }
  }
</script>

Properties

PropertyTypeDefaultRequiredDescription
thresholdArray[0.2]noMDN docs
rootHTMLElementnullnoMDN docs
rootMarginString0px 0px 0px 0pxnoMDN docs

Events

NameArgumentsDescription
intersectednoneEvent fired on intersected.

Polyfill

The IntersectionObserver API is not currently available in all browsers (IE11, Safari and iOS Safari). If you intend to support these browsers, you'll need to add a poylfill to your bundle.

WICG IntersectionObserver Polyfill is higly recommended.

FAQs

Package last updated on 13 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts