diff --git a/packages/gallery/src/components/gallery/proGallery/galleryContainer.js b/packages/gallery/src/components/gallery/proGallery/galleryContainer.js index ca4da9a24..297fe5d0e 100644 --- a/packages/gallery/src/components/gallery/proGallery/galleryContainer.js +++ b/packages/gallery/src/components/gallery/proGallery/galleryContainer.js @@ -192,8 +192,9 @@ export class GalleryContainer extends React.Component { }; const getSignificantProps = (props) => { - const { id, options, container, items, isInDisplay } = props; - return { id, options, container, items, isInDisplay }; + const { id, options, container, items, isInDisplay, isPrerenderMode } = + props; + return { id, options, container, items, isInDisplay, isPrerenderMode }; }; if (this.reCreateGalleryTimer) { @@ -298,15 +299,17 @@ export class GalleryContainer extends React.Component { ); } - getVisibleItems(items, container) { + 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) isSEOMode() || isEditMode() || gotFirstScrollEvent || scrollY > 0 || + isPreviewMode() || this.props.activeIndex > 0 ) { return items; diff --git a/packages/gallery/src/components/gallery/proGallery/galleryView.js b/packages/gallery/src/components/gallery/proGallery/galleryView.js index 08a60afcb..a1079d5cd 100644 --- a/packages/gallery/src/components/gallery/proGallery/galleryView.js +++ b/packages/gallery/src/components/gallery/proGallery/galleryView.js @@ -152,7 +152,11 @@ class GalleryView extends React.Component { ? 'auto' : this.props.container.galleryWidth - options.imageMargin; - const items = getVisibleItems(galleryStructure.galleryItems, container); + const items = getVisibleItems( + galleryStructure.galleryItems, + container, + this.props.isPrerenderMode + ); const itemsWithVirtualizationData = getItemsInViewportOrMarginByScrollLocation({ items, diff --git a/packages/gallery/src/components/gallery/proGallery/slideshowView.js b/packages/gallery/src/components/gallery/proGallery/slideshowView.js index 2f10a6776..089d6386b 100644 --- a/packages/gallery/src/components/gallery/proGallery/slideshowView.js +++ b/packages/gallery/src/components/gallery/proGallery/slideshowView.js @@ -106,11 +106,17 @@ class SlideshowView extends React.Component { } isAllItemsLoaded() { - const { totalItemsCount, getVisibleItems, galleryStructure, container } = - this.props; + const { + totalItemsCount, + getVisibleItems, + galleryStructure, + container, + isPrerenderMode, + } = this.props; const visibleItemsCount = getVisibleItems( galleryStructure.galleryItems, - container + container, + isPrerenderMode ).length; return visibleItemsCount >= totalItemsCount; } @@ -625,9 +631,14 @@ class SlideshowView extends React.Component { getBufferedItems(galleryGroups, container) { const { state, props } = this; - const { options, virtualizationSettings, getVisibleItems } = props; + const { + options, + virtualizationSettings, + getVisibleItems, + isPrerenderMode, + } = props; const { activeIndex } = state; - const groups = getVisibleItems(galleryGroups, container); + const groups = getVisibleItems(galleryGroups, container, isPrerenderMode); const galleryWidth = this.props.galleryContainerRef?.clientWidth || container.galleryWidth ||