reactjs-ui / reactjs-iscroll

基于 iscroll react 组件
MIT License
34 stars 16 forks source link

pullDown设置为false有错误 #1

Open LayGit opened 8 years ago

LayGit commented 8 years ago

pullDown={false} 会导致错误:Cannot read property 'offsetHeight' of undefined

hopefuture commented 8 years ago

该 bug 已修复,谢谢指正!请下载最新版本 0.3.1 同时添加了禁止向上和向下滑动相关逻辑,并给出了例子供参考 另外增加了属性 style 可以定制其样式

LayGit commented 8 years ago

更新到 0.3.1 版本后 pullDown 问题验证已解决。 现在有另外一个问题:pullUp={false} 的时候,高度计算貌似有问题,此问题会导致无法滑动或者滑动距离不足,条数少的时候(如 i < 30)无法滑动,条数多的时候(如 i < 50)滑动高度不足 测试浏览器版本:Chrome 51.0.2704.84 (64-bit) React 版本:15.1.0 Babel 版本:6.5.2 IScroll 版本:5.2.0 代码:

import React from 'react'
import iScroll from 'iscroll/build/iscroll-probe'
import ReactIScroll from 'reactjs-iscroll'

export default class Test extends React.Component {
  constructor (props) {
    super(props)
    this.state = {
      data: []
    }
  }

  componentWillMount() {
    const tempData = []

    for (var i = 0; i < 30; i++) {
      tempData.push({
        id: i,
        name: '测试_' + i
      })
    }

    this.setState({ data: tempData })
  }

  render () {
    return (
      <ReactIScroll iScroll={iScroll} pullDown={false} pullUp={false}>
        <ul>
          {this.state.data.map((item) =>
            <li key={item.id}>{item.name}</li>
          )}
        </ul>
      </ReactIScroll>
    )
  }
}
hopefuture commented 8 years ago

该组件已不再维护,请用我最新的下拉刷新,上拉加载更多 https://github.com/reactjs-ui/reactjs-pull-refresh 也可用 https://github.com/reactjs-ui/reactjs-scroll,只处理滑动效果