Skip to content

Commit

Permalink
Merge pull request #581 from inokawa/remove-window-onscroll-offset
Browse files Browse the repository at this point in the history
Remove offset argument of onScroll prop from WindowVirtualizer
  • Loading branch information
inokawa authored Dec 14, 2024
2 parents b02d7f2 + 18c0957 commit 07a9bf9
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 07a9bf9

Please sign in to comment.