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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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/Virtualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,8 @@
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 @@
}
);
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 @@ -322,7 +322,7 @@
scrollTo: scroller.$scrollTo,
scrollBy: scroller.$scrollBy,
};
}, []);

Check warning on line 325 in src/react/Virtualizer.tsx

View workflow job for this annotation

GitHub Actions / check

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

for (let i = startIndex, j = endIndex; i <= j; i++) {
items.push(getListItem(i));
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 @@
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
7 changes: 3 additions & 4 deletions src/vue/VList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export const VList = /*#__PURE__*/ defineComponent({
setup(props, { emit, expose, slots }) {
const horizontal = props.horizontal;

const onScroll = (offset: number) => {
emit("scroll", offset);
const onScroll = () => {
emit("scroll");
};
const onScrollEnd = () => {
emit("scrollEnd");
Expand Down Expand Up @@ -116,9 +116,8 @@ export const VList = /*#__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
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
Loading