Skip to content

xiaomaAAA/scroll

Repository files navigation

1、搬用 老大的组件 (若侵权立刻下架)QaQ

2、感谢老大 ,膜拜老大

3. props

props type isRequired default desc
defaultScrollTop number false 0 默认滚动位置
className string false '' css名字
onScroll func false () => {} 传递一个方法如修改状态等
element func false 200 获取的节点
isScrollBottom boolean false 是否滚动到底部
scrollBottom number false 滚动高度 - 节点的可视高度
scrollTop number false 滚动距顶部

4. 示例

import React from 'react';
import useScroll from 'src/useScroll';

export default class Layout extends React.Component {

  static propTypes = {};

  static defaultProps = {};

  constructor(props) {
    super(props);
    this.state = {};
          this.srcollTopRef = React.createRef();
  }

  componentDidMount() {}

  renderScrollMenus() {
    let pics = [1, 1,, 1, 1, 1];
    return (
      <Scroll width={230} height={1110} ref={this.srcollTopRef} onScroll={() => {
        const {scrollBottom, scrollTop} = this.srcollTopRef.current;
        const {isBottom} = this.state;
        if (scrollBottom - scrollTop < 10 && !isBottom || scrollTop >= 120) {
          this.setState({
            isBottom: true,
          });
        } else if (isBottom) {
          this.setState({
            isBottom: false,
          });
        }
      }
      }>
        <ul className={css.listBox}>
          {
            pics.map((item, index) => {
              return (
                <li key={index}>
                  <div className={css.yellowLine}/>
                  <div className={css.content}>{item.chinese}</div>
                </li>
              );
            })
          }
        </ul>
      </Scroll>
    );
  }

  render() {
    return this.renderScrollMenus();
  }
}

About

srcoll 滚动组件

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published