All Projects → heavyy → Vue Intersect

heavyy / Vue Intersect

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

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Intersect

vue-sfc-cli
🔨A powerful tool for developing vue single-file component
Stars: ✭ 137 (-52.6%)
Mutual labels:  vue-components
Imagvue
🎑 Imagvue is an image component for Vue.js
Stars: ✭ 268 (-7.27%)
Mutual labels:  vue-components
Ngvue
Use Vue2 components in Angular 1.x
Stars: ✭ 280 (-3.11%)
Mutual labels:  vue-components
Tui
This is a high quanlity components library for VUE
Stars: ✭ 258 (-10.73%)
Mutual labels:  vue-components
Vue Patterns
Useful Vue patterns, techniques, tips and tricks and helpful curated links.
Stars: ✭ 2,898 (+902.77%)
Mutual labels:  vue-components
Vue Turbolinks
A Vue mixin to fix Turbolinks caching
Stars: ✭ 272 (-5.88%)
Mutual labels:  vue-components
vui-vc-next
Vue 3 with Vite Playground - Mobile web UI components - (vue3+vite2).
Stars: ✭ 15 (-94.81%)
Mutual labels:  vue-components
Mint Ui
Mobile UI elements for Vue.js
Stars: ✭ 16,471 (+5599.31%)
Mutual labels:  vue-components
Form Create
🔥🔥🔥 强大的动态表单生成器|form-create is a form generation component that can generate dynamic rendering, data collection, verification and submission functions through JSON.
Stars: ✭ 3,698 (+1179.58%)
Mutual labels:  vue-components
Rubik
Material Design 风格的 Vue.js UI 组件库
Stars: ✭ 277 (-4.15%)
Mutual labels:  vue-components
Vue Image Lightbox
A Vue component to display an image gallery lightbox
Stars: ✭ 258 (-10.73%)
Mutual labels:  vue-components
Formvuelar
Vue form components with server-side validation in mind
Stars: ✭ 263 (-9%)
Mutual labels:  vue-components
V Track
🕹 A manual tracking decoupling plugin based on Vue directive / 一个基于Vue指令实现的埋点解耦插件~
Stars: ✭ 277 (-4.15%)
Mutual labels:  vue-components
Vue Spinners
💫 A collection of loading spinner components for Vuejs
Stars: ✭ 255 (-11.76%)
Mutual labels:  vue-components
Ly Tab
A better mobile touch-swappable reusable component for Vue 2.0
Stars: ✭ 281 (-2.77%)
Mutual labels:  vue-components
codemirror-editor-vue3
CodeMirror component for Vue3
Stars: ✭ 22 (-92.39%)
Mutual labels:  vue-components
Nutui
京东风格的移动端 Vue2、Vue3 组件库 (A Vue.js UI Toolkit for Mobile Web)
Stars: ✭ 3,870 (+1239.1%)
Mutual labels:  vue-components
Vue Testing Examples
Advanced testing with vuejs. When you need to go beyond Getting started section and see some real world example with everything that proper tests should have.
Stars: ✭ 288 (-0.35%)
Mutual labels:  vue-components
Mand Mobile
💰 A mobile UI toolkit, based on Vue.js 2, designed for financial scenarios.
Stars: ✭ 3,194 (+1005.19%)
Mutual labels:  vue-components
Mui Vue2
mui+mint+vue2.x+vue-router+vuex+webpack最终打包成原生apk的app项目,样式使用vue移动端mint ui框架,原生手机能力偏重于mui框架,欢迎star!
Stars: ✭ 278 (-3.81%)
Mutual labels:  vue-components

Vue Intersect

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

npm version Coverage Status Build status

Table of content

Introduction

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

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

Demo

We've made a basic demo of how you might want to use vue-intersect. The code is available in the gh-pages branch and the part where vue-intersect is used can be found here.

Hackernews infinite scroll demo

Please keep in mind that the demo is not production code. Use it as an inspiration.

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 @enter="msg = 'Intersected'" @leave="msg = 'Not intersected'">
    <div>{{ msg }}</div>
  </intersect>
</template>

<script>
  import Intersect from 'vue-intersect'

  export default {
    components: { Intersect },
    data () {
      return {
        msg: 'I will change'
      }
    }
  }
</script>

Properties

Property Type Default Required Description
threshold Array [0, 0.2] no MDN docs
root HTMLElement null no MDN docs
rootMargin String 0px 0px 0px 0px no MDN docs

Events

Name Arguments Description
change IntersectionObserverEntry Event fired on any inte.
enter IntersectionObserverEntry Event fired when the element is intersected (visible on the screen)
leave IntersectionObserverEntry Event fired when the element is not intersected (not visible on the screen)
destroyed None Fired when the underlying element is destroyed

The enter and leave event is sugar, for an often performed operation. You still have to set the threshold to e.g. [0, 0.2] (default). If you leave out "0", it will never call the leave event.

The events is compliant with Vue's event modifiers. This means that you could add .once to the events to make sure you only trigger your event handler once.

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 highly recommended.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].