0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-14 10:42:38 +00:00

small cleanups

This commit is contained in:
Trevor Buckner
2024-12-09 17:06:26 -05:00
parent aa951ff96c
commit 870a4c3363

View File

@@ -46,11 +46,10 @@ const BrewPage = (props)=>{
const visibleObserver = new IntersectionObserver( const visibleObserver = new IntersectionObserver(
(entries)=>{ (entries)=>{
entries.forEach((entry)=>{ entries.forEach((entry)=>{
if(entry.isIntersecting){ if(entry.isIntersecting)
props.onVisibilityChange(props.index + 1, true); // add page to array of visible pages. props.onVisibilityChange(props.index + 1, true); // add page to array of visible pages.
} else { else
props.onVisibilityChange(props.index + 1, false); props.onVisibilityChange(props.index + 1, false);
}
}); });
}, },
{ threshold: .3, rootMargin: '0px 0px 0px 0px' } // detect when >30% of page is within bounds. { threshold: .3, rootMargin: '0px 0px 0px 0px' } // detect when >30% of page is within bounds.
@@ -60,9 +59,8 @@ const BrewPage = (props)=>{
const centerObserver = new IntersectionObserver( const centerObserver = new IntersectionObserver(
(entries)=>{ (entries)=>{
entries.forEach((entry)=>{ entries.forEach((entry)=>{
if(entry.isIntersecting) { if(entry.isIntersecting)
props.onCenterPageChange(props.index + 1); // Set this page as the center page props.onCenterPageChange(props.index + 1); // Set this page as the center page
}
}); });
}, },
{ threshold: 0, rootMargin: '-50% 0px -50% 0px' } // Detect when the page is at the center { threshold: 0, rootMargin: '-50% 0px -50% 0px' } // Detect when the page is at the center