question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

topOffset not working

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Comments:18

github_iconTop GitHub Comments

2reactions
ChrisCinellicommented, May 26, 2017

Nevermind. I did not understand what topOffset is. The name is a little confusing. What I wanted to do is doable with a negative bottomOffset.

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.

1reaction
ChrisCinellicommented, May 26, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found