An infinite scroll plugin for Vue.js.

Overview

Intro

An infinite scroll plugin for Vue.js, to help you implement an infinite scroll list more easily.

Features

  • Mobile friendly
  • Internal spinners
  • 2-directional support
  • Load result message display

Usage & Guide

To check out live examples and docs, visit Vue-infinite-loading GitHub Pages.

Changelog

Detailed changes for each release are documented in the release notes.

Contribution

Please make sure to read the Contributing Guide before making a pull request.

Licence

The MIT License (MIT)

Copyright (c) 2016-present PeachScript

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • "loaded" doesn't stop loading

    v2.1.3 - for some reason the "loaded" emit isn't stopping it from continuing to load results down the page. I'm pretty sure this was working before, but I can't figure out why this is happening.

    So, basically even though I haven't scrolled down, it keeps hitting my server and loading more results. Here's my onInfinite function:

    onInfinite () {
            api.tracks.get(PAGE_AMOUNT, this.tracks.length, tr => {
              console.log(`TRACKS: ${this.tracks.length}`)
    
              if (tr.length > 0) {
                this.tracks = this.tracks.concat(tr)
                if (tr.length < PAGE_AMOUNT) {
                  this.$refs.infiniteLoading.$emit('$InfiniteLoading:complete')
                } else {
                  this.$refs.infiniteLoading.$emit('$InfiniteLoading:loaded')
                }
              } else {
                this.$refs.infiniteLoading.$emit('$InfiniteLoading:complete')
              }
            })
          }
    

    My template:

    <template>
      <div id="track-list">
        <TrackItem v-for='(track, index) in tracks' :track='track' :index="index" :key='track.id'/>
        <infinite-loading :on-infinite="onInfinite" ref="infiniteLoading" spinner="waveDots"></infinite-loading>
      </div>
    </template>
    

    I did put console logs in and it IS hitting that else where it sends the loaded emit. I also changed it to :complete and it stopped calling at that point in the code. So it is emitting, it just seems like its not caring - or for some reason it thinks that its scrolled down.

    Anything I'm doing wrong? Or any ideas on how to debug it further?

    bug 
    opened by DaveSanders 51
  • SSR support

    SSR support

    ¿Will SSR be supported?

    ReferenceError: window is not defined at C:\app\node_modules\vue-infinite-loading\dist\vue-infinite-loading.js:1:12046 at C:\app\node_modules\vue-infinite-loading\dist\vue-infinite-loading.js:1:11978 at p.exports (C:\app\node_modules\vue-infinite-loading\dist\vue-infinite-loading.js:1:12264) at Object. (C:\app\node_modules\vue-infinite-loading\dist\vue-infinite-loading.js:1:12740) at e (C:\app\node_modules\vue-infinite-loading\dist\vue-infinite-loading.js:1:408) at Object.module.exports.render._h.staticClass (C:\app\node_modules\vue-infinite-loading\dist\vue-infinite-loading.js:1:9170) at e (C:\app\node_modules\vue-infinite-loading\dist\vue-infinite-loading.js:1:408) at Object. (C:\app\node_modules\vue-infinite-loading\dist\vue-infinite-loading.js:1:640) at e (C:\app\node_modules\vue-infinite-loading\dist\vue-infinite-loading.js:1:408) at p.__esModule.default (C:\app\node_modules\vue-infinite-loading\dist\vue-infinite-loading.js:1:496)

    enhancement 
    opened by tobeorla 45
  • Using `vue-infinite-loading` with tables

    Using `vue-infinite-loading` with tables

    First of all, thank you for this awesome and easy-to-use component.

    I'm trying to use infinite-loading with ElementUI's fixed-header table. It works fine with a regular table, but as I'm aware, the infinite-loading component needs to be a child of a scrollable element to work properly, which would not be the case if placed next to ElementUI's table component with a fixed header as it separates out the table-body wrapper.

    Demo: https://jsfiddle.net/frya0fLz/

    One of the solutions I thought of would be to have a slot inside the table-body wrapper, but had trouble trying it out.

    Would it be possible to have infinite-loading component hook into the generated element of ElementUI's table?

    bug 
    opened by a-kriya 31
  • Slot and spinner not working when using vue@2.1.7

    Slot and spinner not working when using [email protected]

    Hi,

    I'm using [email protected] and [email protected], and instead of getting the spinner while loading the content, im getting a text "undefined". Everything else works fine. What could be the culprit ?

    Thanks.

    bug 
    opened by altinselimi 28
  • Infinite scroll triggering countinously

    Infinite scroll triggering countinously

    On reaching the bottom, the event triggers multiple time so that the full list is loaded. Is there any particular reason for this? Looks like the plugin didn't get those new elements are added. It keeps on addng...

    opened by gijo-varghese 23
  • * [bug] need to restore the scroll position when direction is top

    * [bug] need to restore the scroll position when direction is top

    • fixed the bug infinite-loading dead loop when the direction is top
    • add a infiniteWrapperClass prop to force infinite wrapper.
    • fixed bug can not used with vue-class-component(ts)

    Sorry I am too lazy to split them. So all in it.

    opened by snowyu 21
  • "You are using the runtime-only" Warning on version 2.2.0

    Version

    2.2.0

    Vue.js version

    2.4.4

    What is exptected?

    To not get this warning, as it was in version 2.1.3

    What is actually happening?

    I am getting a warning: [Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.

    found in

    --->

    How to repreduce this problem?

    Create a version using:

    vue init webpack my-project
    

    with runtime-only configuration.

    enhancement 
    opened by asafyish 21
  • _this.$refs.infiniteLoading.$emit is not a function

    _this.$refs.infiniteLoading.$emit is not a function

    code: loadMore: function () { console.log("loadMore") getChartDetail({id: this.charts[this.activeIndex]['id'],offset:this.chartsArray[this.activeIndex].length}).then(e=>{ this.chartsArray[this.activeIndex].push(...e.books) this.$refs.infiniteLoading&&this.$refs.infiniteLoading.$emit('$InfiniteLoading:loaded'); }).catch(e => { console.log(e) }) } first time it will work,but when i continue to scroll ,next time will produce error ‘_this.$refs.infiniteLoading.$emit is not a function’

    enhancement 
    opened by tengqingya 18
  • Infinite event is not fired since 2.2.2

    Infinite event is not fired since 2.2.2

    Version

    2.2.2

    Vue.js version

    2.4.2 (with nuxt 1.0.0-rc11)

    What is expected?

    infinite-loading should fire 'infinite' event as usual

    What is actually happening?

    the event is not fired anymore since 2.2.2 (working in 2.2.1)

    How to reproduce this problem?

    Use the component as usual, but the handler is never called:

    <no-ssr>
      <InfiniteLoading @infinite="infiniteHandler"></InfiniteLoading>
    </no-ssr>
    ...
    methods: {
      infiniteHandler ($state) { console.log('never called') },
    },
    
    help wanted 
    opened by rquelen 15
  • Issue Cannot read property '_withTask' of undefined

    Issue Cannot read property '_withTask' of undefined

    Version

    2.2.1

    Vue.js version

    2.5.2

    What is expected?

    I expected to have the same result as the 'Basic use' of the module documentation https://peachscript.github.io/vue-infinite-loading/#!/getting-started/basic

    What is actually happening?

    The spinner doesn't disappear and the error message 'TypeError: Cannot read property '_withTask' of undefined' show up in the console of the browser (I use Chrome)

    How to reproduce this problem?

    I have install the module with npm and i use webpack for compiling my application. Did i need an extra configuration in webpack for the module ?

    (Sorry for my bad english, i'm french ;))

    opened by mtibbo 15
  • Feature: Loading when scroll to top

    Feature: Loading when scroll to top

    Thanks for you library bringing convenience to my job. I encounter a situation that need support of loading from top of scroll element.As lack of feature in this library, I can only implement it by my own,really time wasting. I think this is quite a useful and necessary functionality.I just hope this library can be better and add it. Thanks again for your effort.

    feature 
    opened by Aron-YCS 15
  • Infinite handler does not stop being triggered resulting in fetching the data partially until no more data is provided

    Infinite handler does not stop being triggered resulting in fetching the data partially until no more data is provided

    Version

    2.4.5

    Vue.js version

    2.6.11

    Description

    I'm trying to use Vue infinite loading with a native, body scroll of the browser as presented in this demo.

    The problem is that the data is loaded partially, but also recursively - what I mean is that on page load, even when I don't try to scroll, the infinite handler is triggered and it fetches the next data, but should not.

    The afterwards logic calls $state.complete() after it fetches all the items, so it stops there.

    Reproduction Link

              <infinite-loading
                v-if="showInfinite"
                force-use-infinite-wrapper=".__xd"
                @infinite="handleInfiniteLoader"
              >
                <div slot="no-more"></div>
                <div slot="no-results"></div>
              </infinite-loading>
    

    The handler:

        async handleInfiniteLoader($state: {
         loaded: () => any;
         complete: () => any;
       }) {
         const results = await this.load();
         console.log("results", results);
         if (results.length > 0) {
           $state.loaded();
         } else {
           $state.complete();
         }
       },
    

    BTW it loads 25 items at first, to avoid triggering infinite loader right after the first load. Meaning I'm filling the whole page with items; then only scrolling down should trigger the handler.

    Also, what I tried - I thought the infinite loader is visible at first screen paint and that's why it's recursively triggering the handler. So I tried to load some items on component mounted and wrap infinite-loader inside v-if statement, only to make infinite-loader being rendered after the page is filled with 25 results (meaning infinite loader would render for the first time at the very end of the page, being not visible in the viewport).

    Steps to reproduce

    I cannot make a demo to reproduce the issue today and I think the description I gave is fair enough. I will try to make a demo tomorrow if needed.

    What is Expected?

    The infinite handler should be fired when scrolling actually makes infinite-loading component be visible in the viewport.

    What is actually happening?

    The infinite handler is triggered recursively until all the data is fetched, even without doing any "scroll" at all.

    opened by pbilka46 2
  • Multiple infinite-loading component on same page not working as expected in vue 3

    Multiple infinite-loading component on same page not working as expected in vue 3

    Version

    3.0.0-alpha.0-0

    Vue.js version

    3.2

    Reproduction Link

    You can check the issue here - https://stackblitz.com/edit/vue-ckn2zu?file=src%2FApp.vue

    Steps to reproduce

    1. load the stackblitz page and see the app once it runs. initially it will load the 1st component data, and you can see 2nd component loading icon. once the second component show 'no data available' then first component also affecting.

    What is Expected?

    Each infinite loading component should run separately with its own set of data.

    What is actually happening?

    if one component doesn't have the data then other component also showing 'no data available ' error.

    opened by santhanakrishnanstark 0
  • duplicate data rendering

    duplicate data rendering

    i install this package, everything is work now but if data respone from server contain something like a image or file, it seem to be load again and again like my image highlight bellow, correct the pic is load just one anyone can help with this issue? thanks! 123

    opened by phamduc1235 2
  • Top direction is not working as intended

    Top direction is not working as intended

    I'm making a messaging app like whatsapp, I used infinite loading to load a conversation messages, when selecting a conversation it's supposed to view from the last message and scroll up to view more, to do this I used

    <div class="d-flex flex-column-reverse">
      <!-- load the messages -->
    </div>
    

    this makes the scroll start from the bottom if I put the infinite-loading component after the messages it keeps loading even without scrolling if I put it at the top before the messages it will appear at the bottom and will also keeps loading if I make a parent div and put the infinite-loading before the messages div as a sibling and put direction=top it works fine, but when selecting a conversation, the scroll bar starts from the top making the component load once, while it's supposed to start from the bottom and not load messages till I scroll up.

    opened by muhammad-sayed-mahdy 1
Releases(v2.4.5)
  • v2.4.5(Mar 5, 2020)

  • v2.4.4(Mar 31, 2019)

    Fixed

    • Double trigger bug when init with a scrolled wrapper #228

    Improvements

    • Add missing install method declaration in the TypeScript definition file
    Source code(tar.gz)
    Source code(zip)
  • v2.4.3(Nov 23, 2018)

  • v2.4.2(Nov 23, 2018)

  • v2.4.1(Nov 13, 2018)

    Fixed

    • Keep TypeScript definition file sync with source code
    • Throttle reset bug will trigger double infinite event when reseting plugin #189
    Source code(tar.gz)
    Source code(zip)
  • v2.4.0(Oct 24, 2018)

    Happy Programmer's Day!

    This version contains some notable changes and a lot of new features, you may need to spend some time reading them, I believe these changes can help you build application more easily :)

    Notable changes

    • Deprecate the $InfiniteLoading:reset event, use identifier property instead, because it is not a elegant way that getting the instance and communicate via event. Since this verison, the InfiniteLoading component will be reset whenever the identifier property is changed, so you can change your reset logic like this:
    <template>
      <!-- ... -->
      <infinite-loading :identifier="infiniteId"></infinite-loading>
      <!-- ... -->
    </template>
    <script>
    export default {
      data() {
        return { identifier: +new Date() };
      },
      methods: {
        reset() {
          this.identifier += 1; // or any expression can change identifier value
        },
      },
    };
    </script>
    

    New

    • The scroll height will be save and restore automatically when the direction is set to top, it means we can create a top-direction infinite scroll list out of the box!
    • Support configure default values of props, default contents of slots and default system settings via the plugin API, read more
    • Add a new status named error to control message display when loading error, read more
    • A full-new documentation website, powered by Vuepress

    Improvements

    • To avoid inherit styles when configure complex load message via slot special attr, read more
    • Better logger system, only output error message in production
    Source code(tar.gz)
    Source code(zip)
  • v2.3.5(Oct 12, 2018)

    Improvements

    • The forceUseInfiniteWrapper prop support to pass a CSS selector, contributed by @snowyu through #187
    • Vulnerabilities of dependencies

    Fixed

    • Export bug in TypeScript definition file, contributed by @snowyu through #188
    Source code(tar.gz)
    Source code(zip)
  • v2.3.3(Aug 16, 2018)

  • v2.3.2(Aug 11, 2018)

    Improvements

    • Support passive event listener #173 , contributed by @patrickabkarian
    • Use throttle instead of debounce #160 , contributed by @whdckszxxx
    • Add banner into dist file when bundle in production #154
    Source code(tar.gz)
    Source code(zip)
  • v2.3.1(Apr 10, 2018)

  • v2.2.3(Dec 11, 2017)

  • v2.2.2(Nov 21, 2017)

    Improvements

    • Add responsive support for the force-use-infinite-wrapper property #102
    • Add name property for this component, contributed by @rquelen through #108
    • Reduce duration time for the debounce feature
    • Move spinners to it own component, contributed by @bartekupartek through #98

    Fixed

    • Scroll wrapper search bug if the wrapper element is body, contributed by @SerikDM in #100
    Source code(tar.gz)
    Source code(zip)
  • v2.2.1(Sep 25, 2017)

    Improvements

    • Stop attempt load when this component is invisible #93

    Fixed

    • Replace template to render function for all spinners to prevent pre-compile warning from Runtime-only version of Vue.js #83
    Source code(tar.gz)
    Source code(zip)
  • v2.2.0(Sep 15, 2017)

    Goodbye, the space hero Cassini Huygens!

    This version contains notable changes, so you may need spend some time to update your application through the list below. If you have any suggestion, please join the issues and discuss with us!

    Thanks to all contributors and participants of the related issues to help this component become better:

    @syn-zeta @DaveSanders @Akari1987 @PenAndPapers @rodwin @mcmillion @vbabenko @adamyarger @duyhung85 @JefferyHus @tengqingya @emkman @feinimoshu753 @jkiimm @zzmm1 @xuyukuan @vgladimir @jun9358 @vlahde

    Notable changes

    • Deprecate the on-infinite property, and recommend to use infinite event instead, #75 , doc:
    <infinite-loading v-on:infinite="infiniteHandler"></infinite-loading>
    <!-- or -->
    <infinite-loading @infinite="infiniteHandler"></infinite-loading>
    
    • Deprecate use $InfiniteLoading:loaded and $InfiniteLoading:complete event, and recommend to use the $state special event argument instead, #57 , doc:
    ...
    methods: {
      infiniteHandler($state) {
        ajax('https://www.example.com/api/news')
          .then((res) => {
            if (res.data) {
              $state.loaded();
            } else {
              $state.complete();
            }
          })
      },
    },
    ...
    

    New

    • Add force-use-infinite-wrapper attribute support to prevent be in a infinite loop, #55 :
    <div infinite-wrapper> <!--this div will become the real scroll wrapper -->
      <div style="overflow: auto;">
        <infinite-loading force-use-infinite-wrapper="true"></infinite-loading>
      </div>
    </div>
    

    Improvements

    • Upgrade to Webpack 3.x and optimize configurations for the babel, karma and eslint
    • Optimize all unit tests
    • Support hide any message through a blank slot #61
    • Optimize the scroll event performance #49
    • Move all functions to methods to support extends feature #64
    • Improve the way to render spinners, and keep the bundle size to 19kb after in the above changes
    Source code(tar.gz)
    Source code(zip)
  • v2.1.3(May 27, 2017)

  • v2.1.2(May 20, 2017)

  • v2.1.0(May 14, 2017)

  • v2.0.4(Apr 6, 2017)

  • v2.0.3(Mar 9, 2017)

  • v1.3.2(Mar 9, 2017)

  • v2.0.2(Feb 23, 2017)

  • v1.3.1(Feb 22, 2017)

  • v2.0.0(Jan 18, 2017)

    New

    • Add direction property to support load data when scroll to top #20

    Improvements

    • Support continue loading if the previous load cannot fill up container #21
    Source code(tar.gz)
    Source code(zip)
  • v1.3.0(Jan 13, 2017)

  • v1.2.0(Jan 12, 2017)

  • v2.0.0-rc.5(Dec 30, 2016)

  • v2.0.0-rc.4(Dec 14, 2016)

  • v2.0.0-rc.3(Nov 8, 2016)

  • v1.1.4(Nov 8, 2016)

  • v2.0.0-rc.2(Oct 28, 2016)

Owner
Peach
Don't forget your beginner's mind.
Peach
A plugin that can help you create project friendly with Vue for @vue/cli 4.5

vue-cli-plugin-patch A plugin that can help you create project friendly with Vue for @vue/cli 4.5. Install First you need to install @vue/cli globally

null 2 Jan 6, 2022
:tada: A magical vue admin https://panjiachen.github.io/vue-element-admin

English | 简体中文 | 日本語 | Spanish SPONSORED BY 活动服务销售平台 客户消息直达工作群 Introduction vue-element-admin is a production-ready front-end solution for admin inter

花裤衩 80.1k Dec 31, 2022
:eyes: Vue in React, React in Vue. Seamless integration of the two. :dancers:

vuera NOTE: This project is looking for a maintainer! Use Vue components in your React app: import React from 'react' import MyVueComponent from './My

Aleksandr Komarov 4k Dec 30, 2022
🎉 基于 vite 2.0 + vue 3.0 + vue-router 4.0 + vuex 4.0 + element-plus 的后台管理系统vue3-element-admin

vue3-element-admin ?? 基于 Vite 2.0 + Vue3.0 + Vue-Router 4.0 + Vuex 4.0 + element-plus 的后台管理系统 简介 vue3-element-admin 是一个后台前端解决方案,它基于 vue3 和 element-plu

雪月欧巴 84 Nov 28, 2022
Jenesius vue modal is simple library for Vue 3 only

Jenesius Vue Modal Jenesius vue modal is simple library for Vue 3 only . Site Documentation Installation npm i jenesius-vue-modal For add modals in yo

Архипцев Евгений 63 Dec 30, 2022
A template repository / quick start to build Azure Static Web Apps with a Node.js function. It uses Vue.js v3, Vue Router, Vuex, and Vite.js.

Azure Static Web App Template with Node.js API This is a template repository for creating Azure Static Web Apps that comes pre-configured with: Vue.js

Marc Duiker 6 Jun 25, 2022
Mosha-vue-toastify - A light weight and fun Vue 3 toast or notification or snack bar or however you wanna call it library.

Mosha Vue Toastify A lightweight and fun Vue 3 toast or notification or snack bar or however you wanna call it library. English | 简体中文 Talk is cheap,

Baidi Liu 187 Jan 2, 2023
Veloce: Starter template that uses Vue 3, Vite, TypeScript, SSR, Pinia, Vue Router, Express and Docker

Veloce Lightning-fast cold server start Instant hot module replacement (HMR) and dev SSR True on-demand compilation Tech Stack Vue 3: UI Rendering lib

Alan Morel 10 Oct 7, 2022
:globe_with_meridians: Internationalization plugin for Vue.js

vue-i18n Internationalization plugin for Vue.js ?? Gold Sponsors ?? Silver Sponsors ?? Bronze Sponsors ⚠️ NOTICE This repository is for Vue I18n v8.x.

kazuya kawaguchi 6.9k Jan 8, 2023
Vue2.x plugin to create scoped or global shortcuts. No need to import a vue component into the template.

vue2-shortcut Vue2.x plugin to create scoped or global shortcuts. No need to import a vue component into the template. Install $ npm install --save vu

Graxi 37 Aug 14, 2022
Vue 3 + Vite + SSR template based on Vite Plugin SSR and inspired by Vitesse

Vite Vue SSR Starter Vue 3 + Vite + SSR template based on Vite Plugin SSR and inspired by Vitesse Features ⚡️ Vue 3, Vite 2, TypeScript ?? Domain-Driv

Oleg Koval 10 Aug 2, 2022
🌐 Lightweight internationalization plugin for Vue 3

??️ vue-next-i18n Lightweight internationalization plugin for Vue 3 ?? Getting started To begin, you'll need to install vue-next-i18n use npm npm inst

Aaron Lam 12 Nov 21, 2022
A simple picture clipping plugin for vue

vue-cropper 一个优雅的图片裁剪插件 [ 查看演示 Demo ] [ README_english ] [ 更新日志 ] 一、安装使用 1. 安装 # npm 安装 npm install vue-cropper # yarn 安装 yarn add vue-cropper 如果你没有使用

xyxiao001 3.6k Jan 5, 2023
📓 The UI component explorer. Develop, document, & test React, Vue, Angular, Web Components, Ember, Svelte & more!

Build bulletproof UI components faster Storybook is a development environment for UI components. It allows you to browse a component library, view the

Storybook 75.9k Jan 9, 2023
A Vue.js 2.0 UI Toolkit for Web

A Vue.js 2.0 UI Toolkit for Web. Element will stay with Vue 2.x For Vue 3.0, we recommend using Element Plus from the same team Links Homepage and doc

饿了么前端 53k Jan 3, 2023
The Intuitive Vue Framework

Build your next Vue.js application with confidence using Nuxt: a framework making web development simple and powerful. Links ?? Documentation: https:/

Nuxt 41.8k Jan 5, 2023
🐉 Material Component Framework for Vue

Supporting Vuetify Vuetify is a MIT licensed project that is developed and maintained full-time by John Leider and Heather Leider; with support from t

vuetify 36.2k Jan 3, 2023
🛠️ Standard Tooling for Vue.js Development

Vue CLI Vue CLI is the Standard Tooling for Vue.js Development. Documentation Docs are available at https://cli.vuejs.org/ - we are still working on r

vuejs 29.6k Jan 4, 2023
🗃️ Centralized State Management for Vue.js.

Vuex ?? HEADS UP! You're currently looking at Vuex 3 branch. If you're looking for Vuex 4, please check out 4.0 branch. Vuex is a state management pat

vuejs 27.9k Dec 30, 2022