diff --git a/packages/gallery/src/components/gallery/proGallery/galleryContainer.js b/packages/gallery/src/components/gallery/proGallery/galleryContainer.js index 2284cf553..cdee80d1b 100644 --- a/packages/gallery/src/components/gallery/proGallery/galleryContainer.js +++ b/packages/gallery/src/components/gallery/proGallery/galleryContainer.js @@ -276,7 +276,7 @@ export class GalleryContainer extends React.Component { getVisibleItems(items, container, isPrerenderMode) { const { gotFirstScrollEvent } = this.state; - const scrollY = window.scrollY; + const scrollY = this.state?.scrollPosition?.top || 0; const { galleryHeight, scrollBase, galleryWidth } = container; if ( isPrerenderMode || // (used to be isSSR, had a hydrate bug, isPrerenderMode is the way to go in terms of hydrate issues) @@ -284,6 +284,7 @@ export class GalleryContainer extends React.Component { isEditMode() || gotFirstScrollEvent || scrollY > 0 || + isPreviewMode() || this.props.activeIndex > 0 ) { return items;