1.0.2 • Published 7 months ago

seamless-scroll-react v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

安装

yarn add seamless-scroll-react

# or

npm i seamless-scroll-react

# or

pnpm i seamless-scroll-react

快速上手

import ReactSeamlessScroll, { SeamlessScrollInctance } from 'rc-seamless-scroll';

const list = [
  {
    title: '无缝滚动组件展示数据第1条',
  },
  {
    title: '无缝滚动组件展示数据第2条',
  },
  {
    title: '无缝滚动组件展示数据第3条',
  },
  {
    title: '无缝滚动组件展示数据第4条',
  },
  {
    title: '无缝滚动组件展示数据第5条',
  },
  {
    title: '无缝滚动组件展示数据第6条',
  },
  {
    title: '无缝滚动组件展示数据第7条',
  },
  {
    title: '无缝滚动组件展示数据第8条',
  },
  {
    title: '无缝滚动组件展示数据第9条',
  },
  {
    title: '无缝滚动组件展示数据第10条',
  },
  {
    title: '无缝滚动组件展示数据第11条',
  },
  {
    title: '无缝滚动组件展示数据第12条',
  },
  {
    title: '无缝滚动组件展示数据第13条',
  },
  {
    title: '无缝滚动组件展示数据第14条',
  },
];
const App = () => {
  const ref = React.useRef < SeamlessScrollInctance > null;
  return (
    <ReactSeamlessScroll list={list} ref={ref}>
      {list.map((item, index) => (
        <div key={index}>{item.title}</div>
      ))}
    </ReactSeamlessScroll>
  );
};

SeamlessScrollInstance

  • onReset 重置滚动
  • onStopMove 停止滚动
  • onStartMove 开始滚动

Props

属性描述类型是否必需默认值
isAutoScroll是否开启自动滚动booleantrue
list原始数据列表Record<string, any>[]-
ref引用组件方法SeamlessScrollInstance-
step步进速度,step 也是单步大小的约数number1
limitScrollNum开启滚动的数据大小number3
hover是否开启鼠标悬停booleanfalse
direction控制滚动方向up , down , left , right'up'
singleHeight单步运动停止的高度(每一项的高度)number-
singleWidth单步运动停止的宽度(每一项的宽度)number-
singleWaitTime单步停止等待时间number1000ms
isRemUnit是否开启 rem 单位booleanfalse
delay动画延迟时间number0ms
ease动画方式(与 css 过度效果配置一致)string或者{x1:number,x2:number,y1:number,y2:number}ease-in
count动画循环次数,默认-1 表示一直动画 0 表示不循环number-1
copyNum拷贝几份滚动列表number1
wheel开启鼠标悬停时支持滚轮滚动(hover 为 true 时生效)booleanfalse
wrapperClassName最外层盒子类名string-
wrapperHeight最外层盒子高度numberchildren 列表的高度
children列表节点ReactNode-