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

pulldown-infinity-scroll

v1.0.10

Published

A Better-scroll Pull-down Plugin

Downloads

17

Readme

使用

安装

// with npm
npm install pulldown-infinity-scroll

// with yarn
yarn add pulldown-infinity-scroll

示例

import BScroll from '@better-scroll/core'
import InfinityScroll, {InfinityOptions} from 'pulldown-infinity-scroll'
BScroll.use(InfinityScroll)

const bs = new BScroll('.wrapper', {
  'pulldown-infinity': {
    fetch(count, loadednum) {
      // 获取大于 count 数量的数据,该函数是异步的,它需要返回一个 Promise。
      // 成功获取数据后,你需要 resolve 数据数组(也可以 resolve 一个 Promise)(数据中必须包含id,计算、销毁等都需要id来确认)。
      // 数组的每一个元素是列表数据,在 render 方法执行的时候会传递这个数据渲染。
      // 如果没有数据的时候,你可以 resolve(false),来告诉无限滚动列表已经没有更多数据了。
      // loadednum为已加载的数量
    }
    render(item, div, index) {
      // 渲染每一个元素节点,item 是数据,div 是包裹元素节点的容器, index为当前索引。
      // 该函数需要返回渲染后的 DOM 节点。
      // 在vue2中可以使用 Vue.extend来生成组件并获取组件的dom返回
      // 在vue3(当前最新为3.25)中可以使用 createApp来生成一个应用,然后挂载到指定dom中然后返回
    },
    createTombstone() {
      // 返回一个墓碑 DOM 节点。
    },
    destroy(id) {
      // 当未展示内容销毁时触发
    }
  } as InfinityOptions<fetchData>
})

| Event | Description | 参数 | | ------------------- | ------------------------------------------------------- | ------------------------ | | reset | 刷新scroll,并且重新请求数据 | 无 | | unshift | 手动添加新的数据 | extends {id: string | number} | | resize | 保持滚动位置,重新计算,当列表dom尺寸改变时调用,以保证布局正确 | 无 | | remove | 删除指定数据 | id: string | number | | replace | 替换指定数据 | extends {id: string | number} | | rerender | 保持滚动位置重新渲染内容 | 无 |

示例

bs.trigger('reset');
bs.trigger('resize');
bs.trigger('unshift', chatData);
bs.trigger('replace', chatData);
bs.trigger('remove', id);