🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis
Socket
Book a DemoInstallSign in
Socket

react-pulldown-mobile

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-pulldown-mobile

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

latest
Source
npmnpm
Version
2.0.6
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

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

组件属性

属性名类型说明
containerString下拉容器的querySelector选择器字符串,默认是当前父元素
idString会作为id属性附加到组件的DOM元素上
classNameString会作为class属性附加到组件的DOM元素上,可用于自定义组件的样式
topTipString下拉露出的顶部区域的提示文字
bottomTipString上推露出的底部区域的提示文字
thresholdNumber下拉/上推完成阈值,默认是200
sensitivityNumber下拉/上推灵敏度,请传入0.1-1的数字,默认是0.4
enablePullBoolean开启下拉功能,默认true
enablePushBoolean开启上推功能,默认true
onPullCancelFunction取消下拉后执行的回调函数
onPullDownFunction达到下拉阈值后执行的回调函数
onPullMoveFunction下拉过程中指定的回调函数,可以从参数获取到位移、阈值、灵敏度
onPushCancelFunction取消上推后执行的回调函数
onPushUpFunction达到上推阈值后执行的回调函数
onPushMoveFunction上推过程中指定的回调函数,可以从参数获取到位移、阈值、灵敏度

Keywords

react

FAQs

Package last updated on 24 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts