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-pulldown-mobile

v2.0.6

Published

一个简单的react下拉/上推组件

Downloads

24

Readme

React-pulldown-mobile

一个简单的React下拉/上推组件

示例

import React from 'react'
import ReactDOM from 'react-dom'
import PullDown from '../src'

class PullDownDemo extends React.Component {

  constructor(props) {
    super(props);
    this.state = {
      items: new Array(20).fill('')
    }
  }

  render() {

    return (
      <div className="container">
        <PullDown
          className="foo"
          topTip="PULL DOWN TO RELOAD"
          bottomTip="PUSH UP TO LOAD MORE"
          onPullDown={() => {
            this.reload()
          }}
          onPushUp={() => {
            this.loadMore()
          }}
        >
          <div className="contents">
          {this.state.items.map((v, i) => {
            return <div key={i} className="item"><span>{i + 1}</span></div>
          })}
          </div>
        </PullDown>
      </div>
    )

  }

  reload() {

    this.setState({
      items: new Array(20).fill('')
    })

  }

  loadMore() {

    this.setState({
      items: [ ...this.state.items, ...new Array(15).fill('') ]
    })

  }

}

ReactDOM.render(<PullDownDemo />, document.querySelector('#root'))

该示例已经包含在git项目中,要亲自感受,可以clone此项目,然后在项目目录执行以下命令

npm i && npm run sample && open http://localhost:5998

组件属性

| 属性名 | 类型 | 说明 | | ---------------------- | ------------- | :----- | | container | String | 下拉容器的querySelector选择器字符串,默认是当前父元素 | | id | String | 会作为id属性附加到组件的DOM元素上 | | className | String | 会作为class属性附加到组件的DOM元素上,可用于自定义组件的样式 | | topTip| String | 下拉露出的顶部区域的提示文字 | | bottomTip| String | 上推露出的底部区域的提示文字 | | threshold | Number | 下拉/上推完成阈值,默认是200 | | sensitivity | Number | 下拉/上推灵敏度,请传入0.1-1的数字,默认是0.4 | | enablePull | Boolean | 开启下拉功能,默认true | | enablePush | Boolean | 开启上推功能,默认true | | onPullCancel | Function | 取消下拉后执行的回调函数 | | onPullDown | Function | 达到下拉阈值后执行的回调函数 | | onPullMove | Function | 下拉过程中指定的回调函数,可以从参数获取到位移、阈值、灵敏度 | | onPushCancel | Function | 取消上推后执行的回调函数 | | onPushUp | Function | 达到上推阈值后执行的回调函数 | | onPushMove | Function | 上推过程中指定的回调函数,可以从参数获取到位移、阈值、灵敏度 |