Skip to content

Commit

Permalink
Remove offset argument of onScroll prop from WindowVirtualizer
Browse files Browse the repository at this point in the history
  • Loading branch information
inokawa committed Dec 14, 2024
1 parent b02d7f2 commit 18c0957
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
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 @@ export interface WindowVirtualizerProps {
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 @@ export const WindowVirtualizer = forwardRef<
}
);
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
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

0 comments on commit 18c0957

Please sign in to comment.