some-react-components / react-scrollchor

A React component for scroll to `#hash` links with smooth animations
ISC License
149 stars 24 forks source link

Question: Does this have a scrollspy? #19

Closed talon-himself closed 7 years ago

talon-himself commented 7 years ago

Does this support some sort of scrollspy?

What I mean is that once you scroll over/click to scroll to , is highlighted/bold.

bySabi commented 7 years ago

You can create "after" and "before" scrolled callbacks.

See the API: https://github.com/bySabi/react-scrollchor#before-and-after-animate-callbacks

talon-himself commented 7 years ago

Awesome, thank you for the quick reply. Are there any examples of this being used?

bySabi commented 7 years ago

Take a look a this code: https://github.com/bySabi/react-scrollchor/blob/example/src/App.js#L15 Is the source of:

In this concrete example Sequentially component get refreshed every 1000 ms. You can see that state is set inside _afterAnimate callback function with this._iterator.next().value, iterator is just a helper function that pick a element from an array, ["one", "two", "three"], in a circular way.

I hope this example can illustrate you. Clone the example repo and play with it.

Feel free to ask anything you need.

talon-himself commented 7 years ago

Okay I will look it over, I don't want to click a section and scroll back, I just want to be able to highlight/bold the Scrollchor tag element in my navbar when the user is on that section of the page.

bySabi commented 7 years ago

I see what you want. Well react-scrollchor don't handle onMouseEnter, onMouseLeave, on Focus, ... events by it self. You must provided it See this stackoverflow thread: https://stackoverflow.com/questions/28365233/inline-css-styles-in-react-how-to-implement-ahover

This kinds of behaviour must be handled at navigation components levels using, for example, https://react-bootstrap.github.io/components.html#navigation or similar. But of course you can do it by scratch

bySabi commented 7 years ago

I will close this for now.

Feel free to reopen is needed.