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.

Any way to reference a specific waypoint in the onEnter/onLeave handler?

See original GitHub issue

I have a series of waypoints marking important boundaries on a long, scrolling page. I’d like them all to fire the same onEnter/onLeave handler rather than writing individual handlers for each Waypoint. Would it be possible to pass the key attribute or the id of the waypoint itself as part of the data object these handlers receive?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
trotzigcommented, Mar 13, 2017

Thanks for the follow-up @andremalkine! I’m going to close this issue without any actions, as I think we’ve figured out a good-enough workaround for you and others who might run into the same issue.

0reactions
andremalkinecommented, Mar 9, 2017

@trotzig I have a page with 5 viewport filling “sections”. As the user scrolls, I’m interested in knowing when each new section enters and leaves the viewport. There is an arbitrary amount of content above them, and they can each overflow the viewport and be different heights if needed, so having waypoints is very handy/convenient.

I think the real motivation behind my question was the fact that each enter/leave triggers a very simple, similar action of declaring which section you’re “in”, 0-4. That’s it. Writing that simple behavior over and over just felt odd, and I always try to spawn anonymous functions when rendering.

I like your memoization suggestion, it’s a nice compromise between the two. You may still wind up writing a series of separate but nearly identical functions, but you avoid the aforementioned spawning.

Read more comments on GitHub >

github_iconTop Results From Across the Web

handler option • Waypoints - I Make Web Things
Any function. The handler option is the whole point of Waypoints. This is the function that executes when a waypoint is crossed. This...
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