mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 01:12:44 +00:00
Restore looping over entries. Needed for very fast scrolling
This commit is contained in:
@@ -45,20 +45,24 @@ const BrewPage = (props)=>{
|
|||||||
// Observer for tracking pages within the `.pages` div
|
// Observer for tracking pages within the `.pages` div
|
||||||
const visibleObserver = new IntersectionObserver(
|
const visibleObserver = new IntersectionObserver(
|
||||||
(entries)=>{
|
(entries)=>{
|
||||||
if(entries[0].isIntersecting)
|
entries.forEach((entry)=>{
|
||||||
props.onVisibilityChange(props.index + 1, true, false); // add page to array of visible pages.
|
if(entry.isIntersecting)
|
||||||
else
|
props.onVisibilityChange(props.index + 1, true, false); // add page to array of visible pages.
|
||||||
props.onVisibilityChange(props.index + 1, false, false);
|
else
|
||||||
},
|
props.onVisibilityChange(props.index + 1, false, 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.
|
||||||
);
|
);
|
||||||
|
|
||||||
// Observer for tracking the page at the center of the iframe.
|
// Observer for tracking the page at the center of the iframe.
|
||||||
const centerObserver = new IntersectionObserver(
|
const centerObserver = new IntersectionObserver(
|
||||||
(entries)=>{
|
(entries)=>{
|
||||||
if(entries[0].isIntersecting)
|
entries.forEach((entry)=>{
|
||||||
props.onVisibilityChange(props.index + 1, true, true); // Set this page as the center page
|
if(entry.isIntersecting)
|
||||||
},
|
props.onVisibilityChange(props.index + 1, true, true); // 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
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user