# lists-scroll

> 滚动列表

Latest version **2.0.0** (published 2021-09-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install lists-scroll
pnpm add lists-scroll
yarn add lists-scroll
bun add lists-scroll
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2021-09-23 |
| First published | 2020-12-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 9.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | nanshenwu |
| Maintainers | wyz107635 |

## Links

- npm: https://www.npmjs.com/package/lists-scroll
- npm.io page: https://npm.io/package/lists-scroll

## Dependencies (3)

- [antd](https://npm.io/package/antd.md) ^4.7.0
- [react](https://npm.io/package/react.md) ^16.13.1
- [react-dom](https://npm.io/package/react-dom.md) ^16.13.1

## Recent versions

- 2.0.0 (latest) — 2021-09-23
- 1.0.1 — 2021-01-21
- 1.0.0 — 2020-12-30

## README

# Author

你们的吴男神

# lists-scroll

 滚动列表
 
## install

 npm install --save lists-scroll
 
## usage

```js
import { Row, Col, List } from 'antd';
import React, { memo, useEffect, useState, useRef } from 'react';
import ListScroll from 'lists-scroll';
import { useSelector } from 'umi';
import styles from '../index.less';
import { namespace } from '../models';

/**
 * @name 重点事件预警
 */
const Page = () => {
  const warning = useSelector((state: GPageProps) => state[namespace].warning);
  const loading = useSelector((state: GPageProps) => state.loading).effects[`${namespace}/warning`];
  const listRef = useRef<any>(null)

  useEffect(()=>{
    // 组件初始化
    const listOpts = listRef.current
    if (listOpts) {
      listOpts.loading = loading;
      listOpts.forceUpdate();
    }
  },[loading])


  useEffect(() => {
    const listOpts = listRef.current
    if (listOpts?.list.length === 0 && warning?.length) {
      listOpts.list = warning
      listOpts.timer = 2 * 1000;
      listOpts.startScrollUp();
      listOpts.forceUpdate();
    }
  }, [warning]);

  /**
   * @name 列表行视图
   * @param item col list
   */
  const renderView = (item: any) => {
    const { eventType, submitTime, area, disputeDescribe, index } = item;
    return (
      <List.Item key={index} style={{ border: 0, padding: '2rem 0' }}>
        <Row className={styles.scrollRow}>
          <Col span={6} title={eventType}>{eventType}</Col>
          <Col span={6} title={submitTime}>{submitTime}</Col>
          <Col span={4} title={area}>{area}</Col>
          <Col span={8} title={disputeDescribe}>{disputeDescribe}</Col>
        </Row>
      </List.Item>
    );
  };

  return (
    <div className={styles.warning}>
      <p />
      <span className={styles.title}>重点事件预警</span>
      <div className={styles.line} />
      <div className={styles.content}>
        <Row className={styles.row}>
          <Col span={6}>事件</Col>
          <Col span={6}>日期</Col>
          <Col span={6}>地区</Col>
          <Col span={6}>详情</Col>
        </Row>
        <div className={styles.scroll}>
          <ListScroll ref={(ref) => { listRef.current = ref}} renderView={renderView} />
        </div>
      </div>
    </div>
  );
};
export default memo(Page);
```

## Preview

![输入图片说明](https://images.gitee.com/uploads/images/2020/1230/114625_0628aa5f_5100124.jpeg "Dingtalk_20201230094345.jpg")

---
_Source: https://npm.io/package/lists-scroll · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
