Skip to content

Commit

Permalink
Merge pull request #389 from inokawa/hangle-get-item-offset
Browse files Browse the repository at this point in the history
Add getItemOffset to VirtualizerHandle
  • Loading branch information
inokawa authored Feb 21, 2024
2 parents 0297ca5 + 833665e commit 2a92d85
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/react/Virtualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export interface VirtualizerHandle {
* Get current offsetHeight or offsetWidth.
*/
readonly viewportSize: number;
/**
* Get item offset from start.
* @param index index of item
*/
getItemOffset(index: number): number;
/**
* Scroll to the item specified by index.
* @param index index of item
Expand Down Expand Up @@ -296,6 +301,7 @@ export const Virtualizer = forwardRef<VirtualizerHandle, VirtualizerProps>(
get viewportSize() {
return store._getViewportSize();
},
getItemOffset: store._getItemOffset,
scrollToIndex: scroller._scrollToIndex,
scrollTo: scroller._scrollTo,
scrollBy: scroller._scrollBy,
Expand Down
6 changes: 6 additions & 0 deletions src/solid/Virtualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export interface VirtualizerHandle {
* Get current offsetHeight or offsetWidth.
*/
readonly viewportSize: number;
/**
* Get item offset from start.
* @param index index of item
*/
getItemOffset(index: number): number;
/**
* Scroll to the item specified by index.
* @param index index of item
Expand Down Expand Up @@ -215,6 +220,7 @@ export const Virtualizer = <T,>(props: VirtualizerProps<T>): JSX.Element => {
get viewportSize() {
return store._getViewportSize();
},
getItemOffset: store._getItemOffset,
scrollToIndex: scroller._scrollToIndex,
scrollTo: scroller._scrollTo,
scrollBy: scroller._scrollBy,
Expand Down
1 change: 1 addition & 0 deletions src/vue/VList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const VList = /*#__PURE__*/ defineComponent({
get viewportSize() {
return handle.value!.viewportSize;
},
getItemOffset: (...args) => handle.value!.getItemOffset(...args),
scrollToIndex: (...args) => handle.value!.scrollToIndex(...args),
scrollTo: (...args) => handle.value!.scrollTo(...args),
scrollBy: (...args) => handle.value!.scrollBy(...args),
Expand Down
6 changes: 6 additions & 0 deletions src/vue/Virtualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export interface VirtualizerHandle {
* Get current offsetHeight or offsetWidth.
*/
readonly viewportSize: number;
/**
* Get item offset from start.
* @param index index of item
*/
getItemOffset(index: number): number;
/**
* Scroll to the item specified by index.
* @param index index of item
Expand Down Expand Up @@ -171,6 +176,7 @@ export const Virtualizer = /*#__PURE__*/ defineComponent({
get viewportSize() {
return store._getViewportSize();
},
getItemOffset: store._getItemOffset,
scrollToIndex: scroller._scrollToIndex,
scrollTo: scroller._scrollTo,
scrollBy: scroller._scrollBy,
Expand Down

0 comments on commit 2a92d85

Please sign in to comment.