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.

`onLeave` isn't fired when `onPositionChange` does

See original GitHub issue
        <Waypoint
          onPositionChange={position => console.log(position)}
          scrollableAncestor={typeof window !== 'undefined' && window}
          onEnter={this.showHeaderButtons}
          onLeave={this.hideHeaderButtons} />

onLeave fires when scrolling normally. But when scrolled to the bottom of the page and then refreshing the page the browser scrolls to the bottom when the page has been loaded and while onPositionChange fires correctly with the above updated position onLeave doesn’t get called at all.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11

github_iconTop GitHub Comments

2reactions
jamespleasecommented, Feb 22, 2017

As an aside, I could be convinced of there being a callback as a prop that is fired immediately when the component mounts, which is passed the initial position. To implement this, we would need the callback prop to be called after this line.

An example API would be:

<Waypoint
  onMount={initialPosition => console.log(`This waypoint mounted at ${initialPosition}`)}
  onEnter={this.onEnter}/>

I’m not convinced that we need this right now, but if someone could show that it:

  1. enables them to do something they cannot do with a workaround
  2. enables them to clean up a really messy workaround to be much cleaner

then I’d likely be 👍 for this new prop.

1reaction
jamespleasecommented, Feb 22, 2017

I was thinking that, @lencioni . I can PR a thing up later today, unless you’d like to take a stab at it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

onLeave isn't fired when onPositionChange does #155 - GitHub
onLeave fires when scrolling normally. But when scrolled to the bottom of the page and then refreshing the page the browser scrolls to...
Read more >
onChange event is not getting fired on react - Stack Overflow
onChange will be triggered only when the textbox element loses focus. You may look for the oninput event.
Read more >
react-waypoint - npm
A waypoint normally fires onEnter and onLeave as you are scrolling, but it can fire because of other events too: When the window...
Read more >
react-waypoint@9.0.3 | runpkg
If `str` isn't a percentage, then `undefined` will be returned. ... If the scroll event isn't fired often enough to occur while the....
Read more >
brigade - Bountysource
onPositionChange, onEnter and onLeave fire once on page load, and won't fire again until reload ... Its instance type 'Waypoint' is not a...
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