- Notifications
You must be signed in to change notification settings - Fork31
mauricevancooten/react-anchor-link-smooth-scroll
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
React component for anchor links using thesmoothscroll polyfill.
Install dependency:
npm install react-anchor-link-smooth-scroll
Add script
importReactfrom'react'importReactDOMfrom'react-dom'importAnchorLinkfrom'react-anchor-link-smooth-scroll'constSmoothScroll=()=>(<div><AnchorLinkhref='#things'>Things</AnchorLink><AnchorLinkhref='#stuff'>Stuff</AnchorLink><sectionid='things'><h2>Things</h2></section><sectionid='stuff'><h2>Stuff</h2></section></div>)ReactDOM.render(<SmoothScroll/>,document.getElementById('content'))
Options; offset the amount of pixels from the top, for if you have a sticky navigation.
Regular offset
<AnchorLinkoffset='100'href='#things'>Things</AnchorLink>
For responsive offset you can provide a function returning the needed integer to scroll from
<AnchorLinkoffset={()=>100}href='#things'>Things</AnchorLink>
v.1.0.11 (July 24th 2018),@ericmasiello Fixed; offset prop from being spread, to avoid remaining props spread to anchor link element.
v1.0.10 (May 30th 2018),@DanMMX Created an option to receive a function for an offset calculation.
v1.0.9 (April 24th 2018),@gazpachu Fix to have hash change in address bar.
v1.0.7 (April 10th 2018),@zauni Fixed problem with nested HTML inside the anchor.
@roborourke Fixed possibility of a custom onClick handler for secondary side effects.
Licensed under theMIT Licence.
About
React component for anchor links using the smooth scroll polyfill.
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors7
Uh oh!
There was an error while loading.Please reload this page.