You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.
Obviously I understand it's firing because they're "in view" but i only want something to happen when they intersect the top and bottom bounds of the root element. How can this be done?
I would think that I could leverage info.isIntersecting but this always seems to evaluate to true.
Current code:
inView(componentEl,(info)=>{console.log(info.isIntersecting)constcurrentYPositionEnter=info.boundingClientRect.topif(currentYPositionEnter<lastYPositionEnter){console.log('Scrolling up, element is entering into view')}elseif(currentYPositionEnter>lastYPositionEnter){console.log(info)console.log('Scrolling down, element is entering into view')}lastYPositionEnter=currentYPositionEnterreturn(leaveInfo)=>{constcurrentYPositionLeave=leaveInfo.boundingClientRect.topif(currentYPositionLeave<lastYPositionLeave){console.log('Scrolling up, element is leaving the view')}elseif(currentYPositionLeave>lastYPositionLeave){console.log('Scrolling down, element is leaving the view')}lastYPositionLeave=currentYPositionLeave}},{root: componentEl.parentElement,})```
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Obviously I understand it's firing because they're "in view" but i only want something to happen when they intersect the top and bottom bounds of the root element. How can this be done?
I would think that I could leverage
info.isIntersecting
but this always seems to evaluate to true.Current code:
Beta Was this translation helpful? Give feedback.
All reactions