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 🙏

© 2025 – Pkg Stats / Ryan Hefner

js-infinite-scroller

v0.1.2

Published

dom回收+无限滚动

Downloads

4

Readme

DOM回收组件

使用方法

安装组件

yarn // or npm install
npm run dev demo //   查看demo

使用组件

import InfiniteScroller from 'dom-collection'

const feedList = document.querySelector('feed选择器');
let ContentSource = function(){};
ContentSource.prototype.fetch = function(){}; // 获取数据的方法
ContentSource.prototype.render = function(item, divObj){};  // 渲染模板的方法,组件会回传当前需要渲染的节点数据和可能存在的可以重用的DOM节点
let feedListConfig = {
  listMarginTop: 0,   //列表距离body顶部的距离,不传则组件自己计算
  runwayItems: 10,    // 当前滚动方向需 保留/提前加载 的节点数,默认为10,此数据必须 >=0
  runwayItemsOpposite: 10,  // 当前滚动反方向需保留的节点数,默认为10
  reusingSelector: 'selector'   // 如果需要DOM重用,则必须提供此选择器,且在获取到的数据节点里第一层必须有对应的字段,用以识别当前回收的DOM类型,以便重用。
}
let feedList = new InfiniteScroller(feedList, new ContentSource(), feedListConfig);

TODO

  1. 处理已被回收的DOM节点高度变化。
  2. 目前只适配了移动端,横竖屏变化仍有待处理。

Change log

v0.1.0

  • init

v0.1.2

  • 列表数据每一项添加__InfiniteScrollerIndex属性,标识在数组中的位置,以便外部调用
  • 修复列表父容器有定位时获取列表距离页面顶部高度的bug