This commit is contained in:
parent
cc85c497c9
commit
fc372a0278
|
|
@ -40,7 +40,7 @@ export default function SwiperCardSection({ data, disableHover=false }: { data:
|
||||||
}
|
}
|
||||||
}, [hashId, data.cardItems, swiperRef])
|
}, [hashId, data.cardItems, swiperRef])
|
||||||
return (
|
return (
|
||||||
<section className={styles.swiperCardSection} id={location.key + hashId} style={{ backgroundImage: `url(${data.backgroundImage})` }}>
|
<section className={styles.swiperCardSection} id={location.pathname + hashId} style={{ backgroundImage: `url(${data.backgroundImage})` }}>
|
||||||
<SectionTitle title={data.title} />
|
<SectionTitle title={data.title} />
|
||||||
<div className={styles.carouselWrapper} >
|
<div className={styles.carouselWrapper} >
|
||||||
{activeIndex > 0 && (
|
{activeIndex > 0 && (
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ export default function TopTabsSection({ data, className }: { data: Data, classN
|
||||||
const sideSlides = sideImageToSlides(data.tabItems[activeIndex]?.sideImage);
|
const sideSlides = sideImageToSlides(data.tabItems[activeIndex]?.sideImage);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section id={location.key + hashId} className={`${styles.topTabsSection} ${className}`} style={{ backgroundImage: `url(${data.backgroundImage})` }}>
|
<section id={location.pathname + hashId} className={`${styles.topTabsSection} ${className}`} style={{ backgroundImage: `url(${data.backgroundImage})` }}>
|
||||||
<div aria-hidden="true">
|
<div aria-hidden="true">
|
||||||
{data.tabItems.map((item,index) => (
|
{data.tabItems.map((item,index) => (
|
||||||
<div key={item.tabName} style={{ height: 0, overflow: "hidden" }} />
|
<div key={item.tabName} style={{ height: 0, overflow: "hidden" }} />
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ const useHashScroll = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!location.hash) {
|
if (!location.hash) {
|
||||||
if(navType === 'PUSH') {
|
if(navType === 'PUSH') {
|
||||||
scrollToWithLenis(0, { immediate: false });
|
// scrollToWithLenis(0, { immediate: false });
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -19,15 +19,13 @@ const useHashScroll = () => {
|
||||||
const maxAttempts = 120;
|
const maxAttempts = 120;
|
||||||
const targetId = decodeURIComponent(location.hash.slice(1));
|
const targetId = decodeURIComponent(location.hash.slice(1));
|
||||||
const tryScrollToHash = () => {
|
const tryScrollToHash = () => {
|
||||||
const element = targetId ? document.getElementById(location.key + targetId) : null;
|
const element = targetId ? document.getElementById(location.pathname + targetId) : null;
|
||||||
console.log('location.key + id', location.key + targetId)
|
|
||||||
console.log('element', element)
|
|
||||||
if (element) {
|
if (element) {
|
||||||
const header = document.querySelector("header");
|
const header = document.querySelector("header");
|
||||||
const headerHeight = header?.getBoundingClientRect().height ?? 7.5 * 16;
|
const headerHeight = header?.getBoundingClientRect().height ?? 7.5 * 16;
|
||||||
scrollToWithLenis(element, {
|
scrollToWithLenis(element, {
|
||||||
offset: -headerHeight,
|
offset: -headerHeight,
|
||||||
duration: 1.1,
|
duration: 1.5,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -38,9 +36,11 @@ const useHashScroll = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// rafId = window.requestAnimationFrame(tryScrollToHash);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
rafId = window.requestAnimationFrame(tryScrollToHash);
|
rafId = window.requestAnimationFrame(tryScrollToHash);
|
||||||
},50)
|
},100)
|
||||||
return () => window.cancelAnimationFrame(rafId);
|
return () => window.cancelAnimationFrame(rafId);
|
||||||
}, [location.pathname, location.hash, navType]);
|
}, [location.pathname, location.hash, navType]);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue