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 🙏

© 2026 – Pkg Stats / Ryan Hefner

rc-waterfall

v1.0.10

Published

Waterfall component for React

Readme

rc-waterfall

Build Status

demo

Install

rc-waterfall

Development

# install
npm install --save rc-waterfall

# run
npm run dev

# build
npm run build

Example

local: http://localhost:3002/

online: http://mapleliu.com/rc-waterfall/

Usage demo

import Waterfall from 'rc-waterfall';
...
<Waterfall
    source = {[...]}
    columnWidth = {200}
    isOnlyImg
    renderItem = {(ci,si,url)=><div><img src={url}/><h4>{si}</h4></div>}
    getTarget = {()=>window}
/>

API

| 参数 | 说明 | 类型 | 默认值 | 可选值 | |-----------|-----------|-----------|-------------|-------------| | source | 图片资源列表 | array | - | - | | columnWidth | 单列宽度【单位px】 | number | 210 | - | | isOnlyImg | 是否只根据图片高度进行排版 | boolean | false | true,false | | renderItem | 渲染瀑布流块元素,回调参数【图片在列中位置ci:number,图片在source中位置si:number,图片url:string】 | function(ci,si,url):ReactNode | (ci,si,url)=><img src={url}/> | - | | getTarget | 设置需要监听其滚动事件的元素,值为一个返回对应 DOM 元素的函数 | function():HTMLElement | ()=>window | - |

Ideas

初始化

  • 通过列宽【columnWidth】与容器【父级元素】宽度算出可显示列数columnNum,生成对应数量的列元素列表columns,且每列有一个图片元素【如果图片数量足够】
  • 执行图片缓存与添加图片元素操作

添加图片元素操作【图片元素实际指renderItem方法返回的ReactDom元素】

  • 判断如果需要添加图片元素,查找最短列并添加图片元素,执行完成后,继续执行添加图片元素操作
  • 判断如果不需要添加图片元素,操作停止

查找最短列

  • 如果根据图片高度排版【isOnlyImg:true】,图片缓存完成后会被添加到一个虚拟dom列表domColumns中,根据domColumns中各列的图片高度和查找最短列
  • 如果根据实际元素高度排版【isOnlyImg:false】,列元素渲染完成后的dom元素会被添加domColumns中,根据domColumns中各列dom元素的实际高度查找最短列

执行添加图片元素时机

  • 初始化完成
  • 上一次添加图片元素渲染完成后
  • getTarget返回的dom滚动条监听事件触发时

判断是否需要添加图片元素

  • 图片是否已全部加载完
  • 图片元素是否已渲染到指定位置

优化处理

  • 图片提前缓存,提升滚动时的流畅度
  • 优化shouldComponentUpdate,避免重复渲染