onEnter always fires on page load even when the component isn't on the viewport
See original GitHub issueHad to add this extra logic in order to make it work properly (just when the component is on the viewport),
this.revealTo(50, true)
is just a custom method that needs to be called when the component is on the viewport.
onEnterViewport = () => {
if (this.state.onViewport === true) this.revealTo(50, true);
this.setState({onViewport: true});
}
And this is at the end of the render:
<Waypoint onEnter={() => this.onEnterViewport()} />
Issue Analytics
- State:
- Created 8 years ago
- Comments:5
Top Results From Across the Web
onEnter always fires on page load even when the component ...
Hi @juancabrera, and thanks for using react-waypoint. We have a test that checks for waypoints outside the viewport on mount. It would be...
Read more >IntersectionObserver callback firing immediately on page load
lazy-load element enters the viewport, but callback() also fires once when the page is initially loaded, which triggers `console.log('observer ...
Read more >GSAP scrollTrigger firing on page load, not “start” trigger ...
I'm trying to make the second block of text on my screen animate when I scroll down on it. The second block of...
Read more >react-waypoint - npm
When the window is resized; When it is mounted (fires onEnter if it's visible on the page); When it is updated/re-rendered by its...
Read more >Release Notes for Ext JS 5.1.3 - Sencha
EXTJS-19592 Image Sprites do not fire sprite events. Events (4) ... EXTJS-16187 Page Analyzer throws error and won't load; EXTJS-16725 Ext.ux.event.
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
hi @trotzig
Thanks for the input.
I have a page where contents display conditionally causing the page height to be dynamically sized on load.
I think i have to put the Waypoint inside the if instead of outside :
I’ll let you know
Are the pages you are referring to publicly accessible? In general, the most common reason that waypoints are triggered prematurely on load is because of dynamic content on the page asynchronously making the page taller. Images for instance, can cause this.
Despite the images taking up 1500px, on initial load they don’t take up any space at all. We can fix this with some css:
This waypoint won’t be triggered until you actually scroll down.
Could this be the case? It doesn’t have to be images at all, there are other types of dynamically sized content that can cause this behavior.
If you add the
debug
prop, there’s a chance you might see something interesting. You can paste the output from it here and I’ll help you too.