topOffset not working
See original GitHub issueI’m trying to trigger onEnter
at a certain distance from the top but they trigger on the “edge” each and every time.
I’ve tried topOffset=“15%” topOffset={50} etc.
The waypoint containing div has position: relative and that div’s container has this.
position: absolute;
perspective: 300px;
width: 100%;
height: 100%;
overflow-x: hidden;
overflow-y: auto
I have a page that is divided in “slides” and the next slide is already slightly visible by making each slide have a height of 98vh
. Unfortunately, this triggers the waypoint for the next slide automatically, which is what I’m trying to avoid by using topOffset
.
Here’s some of the debug output with a topOffset
of 15%.
["waypoint top", 0]
["waypoint bottom", 328.453125]
["scrollableAncestor height", 242]
["scrollableAncestor scrollTop", 0]
["currentPosition", "inside"]
["previousPosition", "inside"]
["waypoint top", 328.453125]
["waypoint bottom", 1234.453125]
["scrollableAncestor height", 242]
["scrollableAncestor scrollTop", 0]
["currentPosition", "below"]
["previousPosition", undefined]
["waypoint top", 1234.453125]
["waypoint bottom", 1764.453125]
["scrollableAncestor height", 242]
["scrollableAncestor scrollTop", 0]
["currentPosition", "below"]
["previousPosition", undefined]
["waypoint top", 1764.453125]
["waypoint bottom", 2449.03125]
["scrollableAncestor height", 242]
["scrollableAncestor scrollTop", 0]
["currentPosition", "below"]
["previousPosition", undefined]
and without a topOffset
["waypoint top", 0]
["waypoint bottom", 328.453125]
["scrollableAncestor height", 242]
["scrollableAncestor scrollTop", 0]
["currentPosition", "inside"]
["previousPosition", "inside"]
["waypoint top", 328.453125]
["waypoint bottom", 1234.453125]
["scrollableAncestor height", 242]
["scrollableAncestor scrollTop", 0]
["currentPosition", "below"]
["previousPosition", undefined]
["waypoint top", 1234.453125]
["waypoint bottom", 1764.453125]
["scrollableAncestor height", 242]
["scrollableAncestor scrollTop", 0]
["currentPosition", "below"]
["previousPosition", undefined]
["waypoint top", 1764.453125]
["waypoint bottom", 2287.03125]
["scrollableAncestor height", 242]
["scrollableAncestor scrollTop", 0]
["currentPosition", "below"]
["previousPosition", undefined]
["waypoint top", 2287.03125]
["waypoint bottom", 2529.03125]
["scrollableAncestor height", 242]
["scrollableAncestor scrollTop", 0]
["currentPosition", "below"]
["previousPosition", undefined]
Issue Analytics
- State:
- Created 7 years ago
- Comments:18
Top Results From Across the Web
topOffset not working · Issue #165 · civiccc/react-waypoint
I'm trying to trigger onEnter at a certain distance from the top but they trigger on the "edge" each and every time.
Read more >React-waypoint topOffset example code or how to use in reactjs
Its really simple, you just need to add it as a prop < Waypoint topOffset="50px" />. For instance, if your app has a...
Read more >HTMLElement.offsetTop - Web APIs | MDN
The HTMLElement.offsetTop read-only property returns the distance of the outer border of the current element relative to the inner border of ...
Read more >My scrollTop value is not working? scrollTop, offsetTop ...
scrollTop is an element property that gets or sets the top position (vertical scroll position) of the selected element.
Read more >HTML DOM Element offsetTop Property - W3Schools
offsetTop; offsetLeft; offsetWidth; offsetHeight. The offset parent is the nearest ancestor that has a position other than static. If no offset parent exists, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Nevermind. I did not understand what
topOffset
is. The name is a little confusing. What I wanted to do is doable with a negativebottomOffset
.It looks like I am not the only one that got it wrong though. It would not be a bad idea to update the example on http://brigade.github.io/react-waypoint/ to show what is what.
It is clear to me now. The offset are relative to the scrolling container and a positive offset means toward the center of the container. But it was obviously not what I was intuitively expecting.