Skip to content

Commit

Permalink
fix: useWindowVirtualizer locking scrolling position (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
piecyk authored Sep 26, 2023
1 parent d4022fd commit e880185
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/react-virtual/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export function useWindowVirtualizer<TItemElement extends Element>(
observeElementRect: observeWindowRect,
observeElementOffset: observeWindowOffset,
scrollToFn: windowScroll,
initialOffset: typeof document !== 'undefined' ? window.scrollY : undefined,
...options,
})
}
2 changes: 2 additions & 0 deletions packages/solid-virtual/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ export function createWindowVirtualizer<TItemElement extends Element>(
observeElementRect: observeWindowRect,
observeElementOffset: observeWindowOffset,
scrollToFn: windowScroll,
initialOffset:
typeof document !== 'undefined' ? window.scrollY : undefined,
},
options,
),
Expand Down
1 change: 1 addition & 0 deletions packages/svelte-virtual/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export function createWindowVirtualizer<TItemElement extends Element>(
observeElementRect: observeWindowRect,
observeElementOffset: observeWindowOffset,
scrollToFn: windowScroll,
initialOffset: typeof document !== 'undefined' ? window.scrollY : undefined,
...options,
})
}
2 changes: 1 addition & 1 deletion packages/virtual-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export const measureElement = <TItemElement extends Element>(
export const windowScroll = <T extends Window>(
offset: number,
{
adjustments = window.scrollY,
adjustments = 0,
behavior,
}: { adjustments?: number; behavior?: ScrollBehavior },
instance: Virtualizer<T, any>,
Expand Down
2 changes: 2 additions & 0 deletions packages/vue-virtual/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export function useWindowVirtualizer<TItemElement extends Element>(
observeElementRect: observeWindowRect,
observeElementOffset: observeWindowOffset,
scrollToFn: windowScroll,
initialOffset:
typeof document !== 'undefined' ? window.scrollY : undefined,
...unref(options),
})),
)
Expand Down

0 comments on commit e880185

Please sign in to comment.