remove smooth scroll and allow gallery image to scroll self
This commit is contained in:
parent
f15f8213b2
commit
5760b436d2
@ -22,10 +22,22 @@ export const shouldUpdateScroll = ({
|
|||||||
pathname,
|
pathname,
|
||||||
}) => {
|
}) => {
|
||||||
if (pathname.startsWith('/photogallery/') && pathname !== '/photogallery/' ) {
|
if (pathname.startsWith('/photogallery/') && pathname !== '/photogallery/' ) {
|
||||||
console.log('scroll to image')
|
// if (prevRouterProps?.location.pathname === '/photogallery/') {
|
||||||
requestAnimationFrame(() => {
|
// console.log('scroll to image from gallery')
|
||||||
window.scrollTo(0, 180);
|
// // setTimeout(() => {
|
||||||
})
|
|
||||||
|
// // window.scrollTo(0, 0);
|
||||||
|
// // }, 100)
|
||||||
|
// setTimeout(() => {
|
||||||
|
// window.scrollTo(0, 180);
|
||||||
|
// }, 10)
|
||||||
|
// } else {
|
||||||
|
// console.log('scroll to image from elsewhere')
|
||||||
|
// requestAnimationFrame(() => {
|
||||||
|
// window.scrollTo(0, 180);
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
console.log('gallery image, skipping')
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (prevRouterProps?.location.pathname === pathname) {
|
if (prevRouterProps?.location.pathname === pathname) {
|
||||||
|
@ -63,6 +63,12 @@ const GalleryImage = ({ data, location: { state } }) => {
|
|||||||
setIsClient(true);
|
setIsClient(true);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
window.scrollTo(0, 180);
|
||||||
|
});
|
||||||
|
}, [image.base]);
|
||||||
|
|
||||||
const nextIndex =
|
const nextIndex =
|
||||||
sortedImageList && currentIndex < sortedImageList.length
|
sortedImageList && currentIndex < sortedImageList.length
|
||||||
? currentIndex + 1
|
? currentIndex + 1
|
||||||
|
@ -94,7 +94,7 @@ const GalleryPage = ({
|
|||||||
}
|
}
|
||||||
navigate(
|
navigate(
|
||||||
getGalleryPageUrl({ sortKey, keyword: filterKeyword, showDebug }, ""),
|
getGalleryPageUrl({ sortKey, keyword: filterKeyword, showDebug }, ""),
|
||||||
{ replace: true, state: { suppressAutoscroll: true } }
|
// { replace: false }
|
||||||
);
|
);
|
||||||
window.removeEventListener("scroll", removeHash);
|
window.removeEventListener("scroll", removeHash);
|
||||||
},
|
},
|
||||||
@ -126,7 +126,7 @@ const GalleryPage = ({
|
|||||||
});
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.addEventListener("scroll", removeHash);
|
window.addEventListener("scroll", removeHash);
|
||||||
}, 900)
|
}, 100)
|
||||||
});
|
});
|
||||||
}, [
|
}, [
|
||||||
hash,
|
hash,
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
:root {
|
:root {
|
||||||
scroll-behavior: smooth;
|
/* scroll-behavior: smooth; */
|
||||||
}
|
}
|
||||||
/* .hero * {
|
/* .hero * {
|
||||||
transition: color .2s, background-color .2s;
|
transition: color .2s, background-color .2s;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user