Socket
Socket
Sign inDemoInstall

@aligilan/infinitescroll

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @aligilan/infinitescroll

Infinite Scroll will emit event when reached at the end of the page


Version published
Weekly downloads
41
increased by105%
Maintainers
1
Install size
5.13 kB
Created
Weekly downloads
 

Readme

Source

nuxt-infinitescroll

An infinite scroll for nuxt applications

Install

npm install @aligilan/infinitescroll --save

Usage

...
modules:[
    '@aligilan/infinitescroll'
],
...
<template>
    <div>
        <ul>
            <li></li>
            <li></li>
            <li></li>
            <infinite-scroll :enough="enough" @load-more="getData()" />
        </ul>
    </div>
</template>

<script>
    data(){
        return{
            dataArray: [],
            ...
            //=======infiniteScroll
            enough: false,
            page: 1,
            pageSize: 10,
            //=====================
            ...
        }
    },
    mounted(){
        this.getData();
    },
    methods:{
        ...
        //=======infiniteScroll
        async getData(){
            try{
                let result = await this.$axios.$get(`my-api-url?page=${this.page++}`);
                if(result.success == 'true'){
                    this.dataArray = this.this.dataArray.concat(result.data);
                    // Stop scroll-loader
                    result.data.length < this.pageSize && (this.enough = true);
                }
            }catch(error){
               console.log('error', error)
            }
        },
        //=====================
        ...
    }
</script>

Options

OptionDescription
:idset an id for loader element.
:enoughflag to visible loader or hide.
:offsetadd offset to current page scroll position, before reach loader position.

Event

@load-more: When page current scroll position reached loader position, will emit this event.

Keywords

FAQs

Last updated on 11 Apr 2020

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