From 0a3ed750fe13ef598b5d47d1ecac41e876b230af Mon Sep 17 00:00:00 2001 From: dadan6 Date: Tue, 6 Jul 2021 15:39:19 +0800 Subject: [PATCH] add onScroll Method in scrollBoard --- src/components/scrollBoard/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/scrollBoard/index.js b/src/components/scrollBoard/index.js index fbea7c4..908cd48 100644 --- a/src/components/scrollBoard/index.js +++ b/src/components/scrollBoard/index.js @@ -151,7 +151,7 @@ function calcAligns(mergedConfig, header) { return deepMerge(aligns, align) } -const ScrollBoard = forwardRef(({ onClick, config = {}, className, style, onMouseOver }, ref) => { +const ScrollBoard = forwardRef(({ onClick, config = {}, className, style, onMouseOver, onScroll }, ref) => { const { width, height, domRef } = useAutoResize(ref) const [state, setState] = useState({ @@ -268,6 +268,11 @@ const ScrollBoard = forwardRef(({ onClick, config = {}, className, style, onMous const animationNum = carousel === 'single' ? 1 : rowNum + if (onScroll) { + const { pause, resume } = task.current || {} + onScroll({ animationIndex, pause, resume, ele: task.current }) + } + let rows = rowsData.slice(animationIndex) rows.push(...rowsData.slice(0, animationIndex)) rows = rows.slice(0, carousel === 'page' ? rowNum * 2 : rowNum + 1) @@ -412,6 +417,7 @@ ScrollBoard.propTypes = { config: PropTypes.object, onClick: PropTypes.func, onMouseOver: PropTypes.func, + onScroll: PropTypes.func, className: PropTypes.string, style: PropTypes.object }