diff --git a/packages/react-virtual/src/index.tsx b/packages/react-virtual/src/index.tsx index 05bebb6f..29c6be8b 100644 --- a/packages/react-virtual/src/index.tsx +++ b/packages/react-virtual/src/index.tsx @@ -81,6 +81,7 @@ export function useWindowVirtualizer( observeElementRect: observeWindowRect, observeElementOffset: observeWindowOffset, scrollToFn: windowScroll, + initialOffset: typeof document !== 'undefined' ? window.scrollY : undefined, ...options, }) } diff --git a/packages/solid-virtual/src/index.tsx b/packages/solid-virtual/src/index.tsx index 8d5b1833..537519f3 100644 --- a/packages/solid-virtual/src/index.tsx +++ b/packages/solid-virtual/src/index.tsx @@ -122,6 +122,8 @@ export function createWindowVirtualizer( observeElementRect: observeWindowRect, observeElementOffset: observeWindowOffset, scrollToFn: windowScroll, + initialOffset: + typeof document !== 'undefined' ? window.scrollY : undefined, }, options, ), diff --git a/packages/svelte-virtual/src/index.ts b/packages/svelte-virtual/src/index.ts index 29169a4e..42621b7e 100644 --- a/packages/svelte-virtual/src/index.ts +++ b/packages/svelte-virtual/src/index.ts @@ -92,6 +92,7 @@ export function createWindowVirtualizer( observeElementRect: observeWindowRect, observeElementOffset: observeWindowOffset, scrollToFn: windowScroll, + initialOffset: typeof document !== 'undefined' ? window.scrollY : undefined, ...options, }) } diff --git a/packages/virtual-core/src/index.ts b/packages/virtual-core/src/index.ts index 9e69ad78..fb1d84aa 100644 --- a/packages/virtual-core/src/index.ts +++ b/packages/virtual-core/src/index.ts @@ -187,7 +187,7 @@ export const measureElement = ( export const windowScroll = ( offset: number, { - adjustments = window.scrollY, + adjustments = 0, behavior, }: { adjustments?: number; behavior?: ScrollBehavior }, instance: Virtualizer, diff --git a/packages/vue-virtual/src/index.ts b/packages/vue-virtual/src/index.ts index be7e7977..8cf49837 100644 --- a/packages/vue-virtual/src/index.ts +++ b/packages/vue-virtual/src/index.ts @@ -106,6 +106,8 @@ export function useWindowVirtualizer( observeElementRect: observeWindowRect, observeElementOffset: observeWindowOffset, scrollToFn: windowScroll, + initialOffset: + typeof document !== 'undefined' ? window.scrollY : undefined, ...unref(options), })), )