From 8eb72621679753f20d6a8a5f014bcba53ee6171e Mon Sep 17 00:00:00 2001 From: pdudhat Date: Thu, 29 Jul 2021 03:35:34 -0400 Subject: [PATCH] fix(virtualizedRenderer): support onScroll listner prop --- src/stories/flex/flex.stories.js | 48 +++++++++++++++- .../virtualized/virtualized.stories.js | 55 ++++++++++++++++++- src/virtualized/virtualizedRenderer.js | 8 ++- 3 files changed, 108 insertions(+), 3 deletions(-) diff --git a/src/stories/flex/flex.stories.js b/src/stories/flex/flex.stories.js index a5fe112..d523ea4 100644 --- a/src/stories/flex/flex.stories.js +++ b/src/stories/flex/flex.stories.js @@ -1,4 +1,4 @@ -import React, { useState, useRef } from 'react' +import React, { useState, useRef, useEffect } from 'react' import { storiesOf } from '@storybook/react' // import { action } from '@storybook/addon-actions' @@ -18,6 +18,7 @@ import Grid, { GridToolContext, } from '../../index' import FilterDemo from './FilterDemo' +import ScrollSyncHelper from '../../ScrollSyncHelper' // const createRow = _ => randomRow(headers) @@ -103,6 +104,50 @@ const OnEditCopyPasteDemo = () => { ) } +const GridWithScrollSync = () => { + const gridRef = useRef() + const divRef = useRef() + + useEffect(() => { + let pane + if (gridRef.current && divRef.current) { + pane = divRef.current + gridRef.current.scrollSync.registerPane(pane, ScrollSyncHelper.HORIZONTAL) + } + return () => { + if (pane) { + gridRef.current.scrollSync.unReisterPane(pane) + } + } + }, []) + + return ( +
+
+
h.width || 150).reduce((sum, val) => sum + val, 0), + }} + > + Scroll Me!!! +
+
+ +
+ ) +} + storiesOf('Flex Grid', module) .add('debug', () => ( )) + .add('Scroll Sync', () => ) .add('Custom Selection Range', () => { const CustomSelectionStory = () => { const initialRect = { x1: 3, y1: 2, x2: 5, y2: 5 } diff --git a/src/stories/virtualized/virtualized.stories.js b/src/stories/virtualized/virtualized.stories.js index 80f431a..bd5ba45 100644 --- a/src/stories/virtualized/virtualized.stories.js +++ b/src/stories/virtualized/virtualized.stories.js @@ -69,7 +69,7 @@ const GridWithScrollTrigger = () => {