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

@vant/waterfall

v1.0.2

Published

vant waterfall component

Downloads

119

Readme

Waterfall 瀑布流

Install

NPM

npm i @vant/waterfall -S

YARN

yarn add @vant/waterfall

使用指南

全局注册

import Vue from 'vue';
import Waterfall from '@vant/waterfall';

Vue.use(Waterfall);

局部注册

如果你只是想在某个组件中使用Waterfall,可以在对应组件中注册Waterfall指令,这样只能在你注册的组件中使用Waterfall

import Waterfall from '@vant/waterfall';

export default {
  directives: {
    WaterfallLower: Waterfall('lower'),
    WaterfallUpper: Waterfall('upper')
  }
};

代码演示

基础用法

使用 v-waterfall-lower 监听滚动到达底部,并执行相应函数。若是函数执行中需要异步加载数据,可以将 waterfall-disabled 指定的值置为 true,禁止 v-waterfall-lower 监听滚动事件

注意:waterfall-disabled 传入的是 vue 对象中表示是否禁止瀑布流触发 key 值,类型是字符串

<ul
  v-waterfall-lower="loadMore"
  waterfall-disabled="disabled"
  waterfall-offset="400"
>
  <li v-for="item in list">{{ item }}</li>
</ul>
export default {
  data() {
    return {
      list: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
      disabled: false
    };
  },

  directives: {
    WaterfallLower: Waterfall('lower')
  },

  methods: {
    loadMore() {
      this.disabled = true;
      setTimeout(() => {
        for (let i = 0; i < 5; i++) {
          this.list.push(this.list.length);
        }
        this.disabled = false;
      }, 200);
    }
  }
};

API

| 参数 | 说明 | 类型 | 默认值 | 版本 | |------|------|------|------|------| | v-waterfall-lower | 滚动到底部, 触发执行的函数 | Function | - | - | | v-waterfall-upper | 滚动到顶部, 触发执行的函数 | Function | - | - | | waterfall-disabled | 在 vue 对象中表示是否禁止瀑布流触发的 key 值 | string | - | - | | waterfall-offset | 触发瀑布流加载的阈值 | number | 300 | - |