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 11, 2024
1 parent 1908d6d commit 713e198
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/react/Virtualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,8 @@ export interface VirtualizerProps {
scrollRef?: RefObject<HTMLElement | null>;
/**
* 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 @@ -268,7 +267,8 @@ export const Virtualizer = forwardRef<VirtualizerHandle, VirtualizerProps>(
}
);
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/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/Virtualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ export const Virtualizer = /*#__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 @@ -295,9 +296,8 @@ export const Virtualizer = /*#__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 713e198

Please sign in to comment.