Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove offset argument of onScroll prop from WindowVirtualizer #581

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/react/WindowVirtualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@
item?: keyof JSX.IntrinsicElements | CustomItemComponent;
/**
* Callback invoked whenever scroll offset changes.
* @param offset Current scrollTop, or scrollLeft if horizontal: true.
*/
onScroll?: (offset: number) => void;
onScroll?: () => void;
/**
* Callback invoked when scrolling stops.
*/
Expand Down Expand Up @@ -198,7 +197,8 @@
}
);
const unsubscribeOnScroll = store.$subscribe(UPDATE_SCROLL_EVENT, () => {
onScroll[refKey] && onScroll[refKey](store.$getScrollOffset());
// https://github.com/inokawa/virtua/discussions/580
onScroll[refKey] && onScroll[refKey]();
});
const unsubscribeOnScrollEnd = store.$subscribe(
UPDATE_SCROLL_END_EVENT,
Expand Down Expand Up @@ -232,7 +232,7 @@
findEndIndex: store.$findEndIndex,
scrollToIndex: scroller.$scrollToIndex,
};
}, []);

Check warning on line 235 in src/react/WindowVirtualizer.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook useImperativeHandle has missing dependencies: 'scroller.$scrollToIndex' and 'store'. Either include them or remove the dependency array

for (let i = startIndex, j = endIndex; i <= j; i++) {
const e = getElement(i);
Expand Down
6 changes: 3 additions & 3 deletions src/solid/WindowVirtualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ export interface WindowVirtualizerProps<T> {
horizontal?: boolean;
/**
* Callback invoked whenever scroll offset changes.
* @param offset Current scrollTop, or scrollLeft if horizontal: true.
*/
onScroll?: (offset: number) => void;
onScroll?: () => void;
/**
* Callback invoked when scrolling stops.
*/
Expand Down Expand Up @@ -130,7 +129,8 @@ export const WindowVirtualizer = <T,>(
});

const unsubscribeOnScroll = store.$subscribe(UPDATE_SCROLL_EVENT, () => {
props.onScroll?.(store.$getScrollOffset());
// https://github.com/inokawa/virtua/discussions/580
props.onScroll?.();
});
const unsubscribeOnScrollEnd = store.$subscribe(
UPDATE_SCROLL_END_EVENT,
Expand Down
3 changes: 2 additions & 1 deletion src/svelte/WindowVirtualizer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
});

const unsubscribeOnScroll = store.$subscribe(UPDATE_SCROLL_EVENT, () => {
onscroll && onscroll(store.$getScrollOffset());
// https://github.com/inokawa/virtua/discussions/580
onscroll && onscroll();
});
const unsubscribeOnScrollEnd = store.$subscribe(
UPDATE_SCROLL_END_EVENT,
Expand Down
3 changes: 1 addition & 2 deletions src/svelte/WindowVirtualizer.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ export interface WindowVirtualizerProps<T> {
horizontal?: boolean;
/**
* Callback invoked whenever scroll offset changes.
* @param offset Current scrollTop, or scrollLeft if horizontal: true.
*/
onscroll?: (offset: number) => void;
onscroll?: () => void;
/**
* Callback invoked when scrolling stops.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/vue/WindowVirtualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ export const WindowVirtualizer = /*#__PURE__*/ defineComponent({
});

const unsubscribeOnScroll = store.$subscribe(UPDATE_SCROLL_EVENT, () => {
emit("scroll", store.$getScrollOffset());
// https://github.com/inokawa/virtua/discussions/580
emit("scroll");
});
const unsubscribeOnScrollEnd = store.$subscribe(
UPDATE_SCROLL_END_EVENT,
Expand Down Expand Up @@ -215,9 +216,8 @@ export const WindowVirtualizer = /*#__PURE__*/ defineComponent({
{
/**
* Callback invoked whenever scroll offset changes.
* @param offset Current scrollTop, or scrollLeft if horizontal: true.
*/
scroll: (offset: number) => void;
scroll: () => void;
/**
* Callback invoked when scrolling stops.
*/
Expand Down
Loading