Skip to content

Commit ebba1ba

Browse files
authored
Merge pull request #10 from StephenWeiXu/dev
PR: Add offset props documentation and fix default value and add security fixes
2 parents 0f99304 + 36f1e94 commit ebba1ba

File tree

5 files changed

+80
-5
lines changed

5 files changed

+80
-5
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
See the [Demo](https://StephenWeiXu.github.io/react-scrollspy-nav-example).
66

77
## Installation
8-
`npm install --save react-scrollspy-nav`
8+
`npm -i react-scrollspy-nav`
99

1010
## Usage
1111
```
@@ -19,6 +19,7 @@ class App extends Component {
1919
<div>
2020
<ScrollspyNav
2121
scrollTargetIds={["section_1", "section_2", "section_3"]}
22+
offset={100}
2223
activeNavClass="is-active"
2324
scrollDuration="1000"
2425
headerBackground="true"
@@ -59,6 +60,7 @@ Props that can be passed to Component `ScrollspyNav` for configuration.
5960
| Name | Type | Description | Example Value |
6061
|------|------|------| ------ |
6162
| scrollTargetIds | Array | List of scroll targets ids | ["section_1", "section_2", "section_3"] |
63+
| offset | Number | offset pixels to the scrollTargetIds. Default is 0 | 100 |
6264
| activeNavClass | String | Class name for styling the nav link that's currently active | "is-active" |
6365
| scrollDuration | String | Scroll duration for controlling how fast the nav click scrolls to its section. Default is "1000" | "1000" |
6466
| headerBackground | String | If header has background color or not, for accurate scroll position, Default is "false" | "true" |

build/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-scrollspy-nav",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "react scrollspy nav component",
55
"main": "build/index.js",
66
"peerDependencies": {
@@ -29,7 +29,8 @@
2929
"webpack-cli": "^3.1.0",
3030
"mem": ">=4.0.0",
3131
"set-value": ">=2.0.1",
32-
"serialize-javascript": ">=2.1.1"
32+
"serialize-javascript": ">=2.1.1",
33+
"tar": ">=2.2.2"
3334
},
3435
"keywords": [
3536
"react",

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ScrollspyNav extends Component {
99
this.activeNavClass = this.props.activeNavClass;
1010
this.scrollDuration = Number(this.props.scrollDuration) || 1000;
1111
this.headerBackground = this.props.headerBackground === "true" ? true : false;
12-
this.offset = this.props.offset;
12+
this.offset = this.props.offset || 0;
1313

1414
if(this.props.router && this.props.router === "HashRouter") {
1515
this.homeDefaultLink = "#/";

0 commit comments

Comments
 (0)