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

ridingwind-scrolllist

v0.0.4

Published

pull-up load more drop-down refresh on mobile, AND scroll load more on PC, React Compopnent

Downloads

11

Readme

ridingwind scrolllist

当前版本 0.0.4

简介

  1. React插件
  2. 只依赖 react/react-dom
  3. 支持代码动态调起刷新和加载更多(组件将展示刷新和加载更多样式)
  4. 支持移动触摸设备(上拉加载,下拉刷新),PC设备滚动加载更多

使用说明

  1. 安装
npm install --save ridingwind-scrolllist
  1. demo
import { RidingWindScrollList, RSTATES } from 'ridingwind-scrolllist';

class Demo extends PureComponent {
  constructor(props) {
    super(props);
    this.state = {
      hasMore: true,
      currentState: RSTATES.init,
      datas: new Array(15).fill('-'), // 测试代码
      index: 5, // 测试代码
    };
  }

  executeFunc = (currentState) => {
    if (currentState === this.state.currentState) {
      return false;
    }

    if (currentState === RSTATES.refreshing) {
      // 刷新
      this.handRefreshing();
    } else if (currentState === RSTATES.loading) {
      // 加载更多
      this.handLoadMore();
    } else {
      this.setState({
        currentState,
      });
    }
  };

  handRefreshing = () => {
    if (RSTATES.refreshing === this.state.currentState) {
      return false;
    }

    setTimeout(() => {
      this.setState({
        hasMore: true,
        currentState: RSTATES.refreshed,
      });
    }, 3000);

    this.setState({
      currentState: RSTATES.refreshing,
    });
  };

  handLoadMore = () => {
    if (RSTATES.loading === this.state.currentState) {
      return false;
    }
    // 无更多内容则不执行后面逻辑
    if (!this.state.hasMore) {
      return;
    }

    setTimeout(() => {
      if (this.state.index === 0) {
        // 测试代码
        this.setState({
          currentState: RSTATES.reset, // 必须
          hasMore: false,
        });
      } else {
        this.setState({
          datas: this.state.datas.concat(new Array(15).fill('-')), // 测试代码
          currentState: RSTATES.reset, // 必须
          index: this.state.index - 1, // 测试代码
        });
      }
    }, 3000);

    this.setState({
      currentState: RSTATES.loading,
    });
  };

  render() {
    const { currentState, hasMore, datas } = this.state;

    return (
      <div>
        <RidingWindScrollList
          id="list"
          pullDownSpace={80}
          actionSpaceBottom={300}
          currentState={currentState}
          hasMore={hasMore}
          executeFunc={this.executeFunc}
          FooterTipDOM={(<div />)}
        >
          {
            datas.map((item, index) => (
              <div
                key={index}
                className={styles.item}
              >
                <div className={styles.itemText}>
                  <div className={styles.itemTextTit}>
                    {index}: {item}国家税务总局:要将税收工作重大决策部署落实到位
                    国家税务总局:要将税收工作重大决策部署落实到位
                  </div>
                  <div className={styles.itemTextInfo}>新浪财经</div>
                </div>
              </div>
            ))
          }
        </RidingWindScrollList>
      </div>
    );
  }
}

export default Demo;

参数说明:

| 参数 | 说明 | 类型 | 备注 | | ---------------- | --------------------------------------------- | ------ | --------------------- | | id | id | String | isRequired | | currentState | 当前状态 | String | isRequired | | executeFunc | 执行的方法 | func | isRequired | | hasMore | 是否还有更多内容可以加载 | Boolean | isRequired | | pullDownSpace | 下拉距离是否满足要求 | Number | isRequired | | actionSpaceBottom | 距离底部多少距离触发加载更多 | Number | isRequired | | FooterTipDOM | 底部提示信息 | Dom | noRequired |

STATS list

| 属性 | 值 | 说明 | | ---------- | ---------------- | -------------------- | | init | '' | 组件初始状态 | | pulling | 'pulling' | 下拉状态 | | enough | 'pullingenough' | 下拉并且已经满足阈值 | | refreshing | 'refreshing' | 刷新中(加载数据中) | | refreshed | 'refreshed' | 完成刷新动作 | | reset | 'reset' | 恢复默认状态 | | loading | 'loading' | 加载中 |

init/reset -> pulling -> enough -> refreshing -> refreshed -> reset

init/reset -> pulling -> reset

init/reset -> loading -> reset