npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vuejs-loadmore

v1.0.8

Published

A pull-down refresh and pull-up loadmore scroll component for Vue.js

Downloads

573

Readme

vuejs-loadmore

Npm Version Build Status

NPM

A pull-down refresh and pull-up loadmore scroll component for Vue.js.

Easy to use by providing simple api. Unlike other component libraries, it uses the browser itself to scroll instead of js, so it has a smaller code size but does not lose the user experience.

English | 中文

Preview

Online demo

You can also scan the following QR code to access the demo:

Installation

Install the npm package

# npm
npm install vuejs-loadmore --save

Import

import Vue from 'vue';
import VueLoadmore from 'vuejs-loadmore';

Vue.use(VueLoadmore);

Internationalization support

Support Chinese zh-CN and English en-US, the default is zh-CN.

import VueLoadmore from 'vuejs-loadmore';

Vue.use(VueLoadmore, {
  lang: 'en-US'
})

You can also use locale.use() to specify the language.

import VueLoadmore, { locale } from 'vuejs-loadmore';

Vue.use(VueLoadmore);
locale.use('en-US');

Usage

Basic Usage

<vue-loadmore 
  :on-refresh="onRefresh" 
  :on-loadmore="onLoad"
  :finished="finished">
  <div v-for="(item, i) of list" :key="i"></div>
</vue-loadmore>

The on-refresh and on-loadmore will be Emitted when pull refresh or scroll to the bottom, you should need to execute the callback function done() after processing the data request.

If you don't need refresh, only not to bind on-refresh.

When the data request is finished, the data of finished you can changed to true, then will show finished-text.

export default {
  data() {
    return {
      list: [],
      page: 1,
      pageSize: 10,
      finished: false
    };
  },
  mounted() {
    this.fetch();
  },
  methods: {
    onRefresh(done) {
      this.list = [];
      this.page = 1;
      this.finished = false;
      this.fetch();

      done();
    },

    onLoad(done) {
      if (this.page <= 10) {
        this.fetch();
      } else {
        // all data loaded
        this.finished = true;
      }
      done();
    },

    fetch() {
      for (let i = 0; i < this.pageSize; i++) {
        this.list.push(this.list.length + 1);
      }
      this.page++;
    }
  },
}

Load Error Info

<vue-loadmore 
  :on-loadmore="onLoad"
  :finished="finished"
  :error.sync="error">
  <div v-for="(item, i) of list" :key="i"></div>
</vue-loadmore>
export default {
  data() {
    return {
      list: [],
      finished: false,
      error: false,
    };
  },
  methods: {
    onLoad() {
      fetchSomeThing().catch(() => {
        this.error = true;
      });
    },
  },
};

API

Props

| Attribute | Description | Type | Default | | --- | --- | --- | --- | | on-refresh | Will be Emitted when pull refresh | function | - | | pulling-text | The Text when pulling in refresh | string | Pull down to refresh | | loosing-text | The Text when loosing in refresh | string | Loosing to refresh | | refresh-text | The Text when loading in refresh | string | Refreshing | | success-text | The Text when loading success in refresh | string | Refresh success | | show-success-text | Whether to show success-text | boolean | true | | pull-distance | The distance to trigger the refresh status | number | string | 50 | | head-height | The height of the area of the refresh shows | number | string | 50 | | animation-duration | Animation duration of the refresh | number | string | 200 | | on-loadmore | Will be Emitted when scroll to the bottom | function | - | | immediate-check | Whether to check loadmore position immediately after mounted | boolean | true | | load-offset | The on-loadmore will be Emitted when the distance from the scroll bar to the bottom is less than the load-offset | number | string | 50 | | finished | Whether the data is loaded | boolean | false | | error | Whether the data is loaded error, the on-loadmore will be Emitted only when error text clicked, the sync modifier is needed | boolean | false | | loading-text | The Text when loading in loaded | string | Loading | | finished-text | The Text when the data is loaded | string | No more data | | error-text | The Text when error loaded | string | Request failed, click to reload |

Methods

Use ref to get List instance and call instance methods.

| Name | Description | Attribute | Return value | | ----- | --------------------- | --------- | ------------ | | checkScroll | Check scroll position | - | - |

Example

You can see the demo for quickly understand how to use this package.

git clone [email protected]:staticdeng/vuejs-loadmore.git
yarn install
yarn example:dev