From 5df63bf44a8b560b8494c1a9794bd1f24bc17a05 Mon Sep 17 00:00:00 2001 From: Chuck Dries Date: Sat, 11 Mar 2023 00:53:16 -0800 Subject: [PATCH] fix gallery image autoscroll, hide hashes on recently published section (and plumb linkstate) --- gatsby-browser.tsx | 1 - src/components/GalleryImage/GalleryImage.js | 4 ++-- src/components/MasonryGallery.tsx | 4 ++-- src/pages/photogallery.tsx | 4 ++++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gatsby-browser.tsx b/gatsby-browser.tsx index 5478107..876a6a0 100644 --- a/gatsby-browser.tsx +++ b/gatsby-browser.tsx @@ -37,7 +37,6 @@ export const shouldUpdateScroll = ({ // window.scrollTo(0, 180); // }) // } - console.log('gallery image, skipping') return false; } if (prevRouterProps?.location.pathname === pathname) { diff --git a/src/components/GalleryImage/GalleryImage.js b/src/components/GalleryImage/GalleryImage.js index ab4ee5e..8481f0d 100644 --- a/src/components/GalleryImage/GalleryImage.js +++ b/src/components/GalleryImage/GalleryImage.js @@ -64,12 +64,12 @@ const GalleryImage = ({ data, location: { state } }) => { }, []); useEffect(() => { - requestAnimationFrame(() => { + setTimeout(() => { window.scrollTo({ top: 180, behavior: 'smooth' }); - }); + }, 50); }, [image.base]); const nextIndex = diff --git a/src/components/MasonryGallery.tsx b/src/components/MasonryGallery.tsx index 9da3b5a..5ffa9ff 100644 --- a/src/components/MasonryGallery.tsx +++ b/src/components/MasonryGallery.tsx @@ -138,8 +138,8 @@ const MasonryGallery = ({ const data = dataFn ? dataFn(image) : null; return (