Compare commits

..

No commits in common. "d704f4d17e83d9df3f61ebd8efc6224d8a372fae" and "88cae53eff1ffc97c4e3cd9337c94a41aec2dff4" have entirely different histories.

3 changed files with 10 additions and 10 deletions

View File

@ -1,7 +1,7 @@
{
"name": "zy-react-library",
"private": false,
"version": "2.0.15",
"version": "2.0.14",
"type": "module",
"description": "",
"author": "LiuJiaNan",

View File

@ -2,7 +2,7 @@ import type { ForwardRefExoticComponent, RefAttributes } from "react";
export interface SeamlessScrollProps {
/** 是否开启自动滚动,默认 true */
isAutoScroll?: boolean;
value?: boolean;
/** 原始数据列表 */
list: unknown[];
/** 步进速度step 需是单步大小的约数,值越大滚动的越快,默认 1 */

View File

@ -6,7 +6,7 @@ import { throttle } from "throttle-debounce";
*/
const SeamlessScroll = forwardRef((props, ref) => {
const {
isAutoScroll = true,
value = true,
list = [],
step = 1,
limitScrollNum = 3,
@ -242,7 +242,7 @@ const SeamlessScroll = forwardRef((props, ref) => {
*
* @description
* 1. 计算并设置容器的宽度和高度
* 2. 如果需要滚动且 isAutoScroll true启动滚动动画
* 2. 如果需要滚动且 value true启动滚动动画
*
* @note
* - React useEffect 中调用可能存在 DOM 未完全渲染的情况
@ -315,7 +315,7 @@ const SeamlessScroll = forwardRef((props, ref) => {
cancle();
};
const hoverStop = hover && isAutoScroll && isScroll; // 是否启用悬停停止功能
const hoverStop = hover && value && isScroll; // 是否启用悬停停止功能
/**
* 重置滚动状态
@ -375,23 +375,23 @@ const SeamlessScroll = forwardRef((props, ref) => {
* - 然后启动滚动
*/
useEffect(() => {
if (isScroll && isAutoScroll && (realBoxHeight > 0 || realBoxWidth > 0) && !isHoverRef.current) {
if (isScroll && value && (realBoxHeight > 0 || realBoxWidth > 0) && !isHoverRef.current) {
move();
}
}, [realBoxHeight, realBoxWidth]);
/**
* 监听 isAutoScroll 属性变化
* isAutoScroll 变化时启动或停止滚动
* 监听 value 属性变化
* value 变化时启动或停止滚动
*/
useEffect(() => {
if (isAutoScroll) {
if (value) {
startMove();
}
else {
stopMove();
}
}, [isAutoScroll]);
}, [value]);
/**
* 监听 count 属性变化