Socket
Socket
Sign inDemoInstall

vue-infinite-scroll

Package Overview
Dependencies
0
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vue-infinite-scroll

An infinite scroll directive for vue.js.


Version published
Weekly downloads
25K
decreased by-0.15%
Maintainers
3
Install size
171 kB
Created
Weekly downloads
 

Readme

Source

vue-infinite-scroll

vue-infinite-scroll is an infinite scroll directive for vue.js.

Install

npm install vue-infinite-scroll --save

CommonJS

You can use any build tool which supports commonjs:

// register globally
var infiniteScroll =  require('vue-infinite-scroll');
Vue.use(infiniteScroll)

// or for a single instance
var infiniteScroll = require('vue-infinite-scroll');
new Vue({
  directives: {infiniteScroll}
})

Or in ES2015:

// register globally
import infiniteScroll from 'vue-infinite-scroll'
Vue.use(infiniteScroll)

// or for a single instance
import infiniteScroll from 'vue-infinite-scroll'
new Vue({
  directives: {infiniteScroll}
})

Direct include

You can use the CDN: https://unpkg.com/vue-infinite-scroll, infiniteScroll is exposed to window and will automatically install itself. Also you can use your local copy:

<script src="../node_modules/vue-infinite-scroll/vue-infinite-scroll.js"></script>

Usage

Use v-infinite-scroll to enable the infinite scroll, and use infinite-scroll-* attributes to define its options.

The method appointed as the value of v-infinite-scroll will be executed when the bottom of the element reaches the bottom of the viewport.

<div v-infinite-scroll="loadMore" infinite-scroll-disabled="busy" infinite-scroll-distance="10">
  ...
</div>
var count = 0;

new Vue({
  el: '#app',
  data: {
    data: [],
    busy: false
  },
  methods: {
    loadMore: function() {
      this.busy = true;

      setTimeout(() => {
        for (var i = 0, j = 10; i < j; i++) {
          this.data.push({ name: count++ });
        }
        this.busy = false;
      }, 1000);
    }
  }
});

Options

OptionDescription
infinite-scroll-disabledinfinite scroll will be disabled if the value of this attribute is true.
infinite-scroll-distanceNumber(default = 0) - the minimum distance between the bottom of the element and the bottom of the viewport before the v-infinite-scroll method is executed.
infinite-scroll-immediate-checkBoolean(default = true) - indicates that the directive should check immediately after bind. Useful if it's possible that the content is not tall enough to fill up the scrollable container.
infinite-scroll-listen-for-eventinfinite scroll will check again when the event is emitted in Vue instance.
infinite-scroll-throttle-delayNumber(default = 200) - interval(ms) between next time checking and this time

Development

CommandDescription
npm run buildBuild in umd format
npm testLint code

License

MIT

Keywords

FAQs

Last updated on 30 Sep 2017

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc