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

react-window-pull-refresh

v1.0.9

Published

react-window-pull-refresh React component

Downloads

7

Readme

react-window-pull-refresh

npm package

该组件为移动端列表展示组件,基于react-window.并添加了下拉刷新和分页加载功能。

效果见Demo

安装

npm install react-window-pull-refresh --save

ReactWindowPullRefresh

使用

import List from 'react-window-pull-refresh'

必传参数

|名称|类型|说明| |--|--|--| |isNextPageLoading|bool|是否正在远程获取下一页数据| |items|array|需要展示的数据的列表数组| |itemRender|function|每项渲染函数的回调function(item,index,style)| |loadNextPage|function|加载下一页的函数回调(startIndex: number, stopIndex: number) => Promise<void>,必须返回Promise对象| |itemHeight|number 或者 function |每项的显示高度,function是用于每项高度不固定的情况|

可选参数

|名称|类型|说明| |--|--|--| |total|number|显示数据的总长度,默认9999 |width|number|列表展示的宽度 |height|number|列表容器的高度,如果不传,组件会填充父元素,建议父元素使用flex布局| |initialScrollOffset|number|列表初始展示的滚动位置,可以配合onScroll做到返回该页面,记录上次滚动的位置| |onScroll|function|滚动的回调function({scrollDirection,scrollOffset,scrollUpdateWasRequested})| |handlePullRefresh|function|下拉刷新的事件回调,如果不传就没有下拉刷新功能function()| |emptyNode|React Node(React组件)|获取的数据为空时,展示的组件| |loadingNode|React Node(React组件)|列表拉到下面切正在加载时,展示的组件| |listOtherProps|object|react-window组件的其他参数,参见,只支持FixedSizeList和VariableSizeList|

PullToRefresh

这个组件可以使其他组件具有下拉刷新的功能

使用

import {PullToRefresh} from 'react-window-pull-refresh'

function Demo ({handlePullRefresh}){
  return <PullToRefresh  handleRefresh={handlePullRefresh}>
                <div>内容区域<div/>
            </PullToRefresh>
}

具体使用方法

更多具体使用方法请参考Demo

注意事项

为了能够正确的计算滚动的高度,请在itemRender函数中将style设置到节点上,代码如下

 itemRender=(item,index,style)=>{
    const myStyle={
      ...style,
      backgroundColor:index%2?'#ffffff':'#e2e2e2',
      display:'flex',
      justifyContent:'center',
      alignItems:'center'
    }
    return (
      <div style={myStyle}>
        {index}: {item}
      </div>
    )
  }