diff --git a/src/core/scroller.ts b/src/core/scroller.ts index 8bf72900..dfc178c2 100644 --- a/src/core/scroller.ts +++ b/src/core/scroller.ts @@ -186,6 +186,7 @@ export type Scroller = { $scrollBy: (offset: number) => void; $scrollToIndex: (index: number, opts?: ScrollToIndexOpts) => void; $fixScrollJump: () => void; + $cancelScroll: () => void; }; /** @@ -369,6 +370,9 @@ export const createScroller = ( $fixScrollJump: () => { scrollObserver && scrollObserver._fixScrollJump(); }, + $cancelScroll: () => { + cancelScroll && cancelScroll(); + }, }; }; diff --git a/src/react/Virtualizer.tsx b/src/react/Virtualizer.tsx index 4eb16756..5671ab9f 100644 --- a/src/react/Virtualizer.tsx +++ b/src/react/Virtualizer.tsx @@ -86,6 +86,10 @@ export interface VirtualizerHandle { * @param offset offset from current position */ scrollBy(offset: number): void; + /** + * Cancel unfinished scroll. + */ + cancelScroll(): void; } /** @@ -321,6 +325,7 @@ export const Virtualizer = forwardRef( scrollToIndex: scroller.$scrollToIndex, scrollTo: scroller.$scrollTo, scrollBy: scroller.$scrollBy, + cancelScroll: scroller.$cancelScroll, }; }, []);