@@ -16,7 +16,7 @@ Include MenuSpy
16
16
17
17
` MenuSpy ` will be available in the global scope.
18
18
19
- Or install via NPM/ Yarn and require as a module
19
+ You can also use NPM / Yarn to install it and then require it as a module.
20
20
21
21
NPM
22
22
30
30
yarn add menuspy
31
31
```
32
32
33
+ Require the module:
34
+
33
35
``` js
34
36
var MenuSpy = require (' menuspy' );
35
37
```
36
38
37
- Initialize the plugin on your menu element
39
+ ---
40
+
41
+ Example of menu element:
38
42
39
43
``` html
40
44
<header id =" main-header" >
@@ -55,6 +59,8 @@ You can also use `data-target` on the anchor element with a selector. Example:
55
59
<a href =" #anything" data-target =" selector" >Anything</a >
56
60
```
57
61
62
+ Initialize the plugin on your menu element.
63
+
58
64
``` js
59
65
var elm = document .querySelector (' #main-header' );
60
66
var ms = new MenuSpy (elm);
@@ -65,11 +71,11 @@ The `MenuSpy()` constructor accepts two arguments: the container element and an
65
71
66
72
## Options
67
73
68
- | Option | Type | Default | Description |
69
- | ---------------------| -------- | -------------------------- | ------------------------------------------------------------------------ |
70
- | ` menuItemSelector ` | String | ` a[href^="#"] ` | Menu items selector. |
71
- | ` activeClass ` | String | ` active ` | Class applied on menu item relative to the currently visible section. |
72
- | ` threshold ` | Integer | ` 15 ` | Ammount of space between your menu and the next section to be activated. |
73
- | ` enableLocationHash ` | Boolean | ` true ` | Enable or disable browser's hash location change. |
74
- | ` hashTimeout ` | Integer | ` 600 ` | Timeout to apply browser's hash location. |
75
- | ` callback ` | Function | ` function(currentItem) {} ` | A function to be called every time a new menu item activates. |
74
+ | Option | Type | Default | Description |
75
+ | ---------------------| -------- | -------------------------- | ----------------------------------------------------------------------- |
76
+ | ` menuItemSelector ` | String | ` a[href^="#"] ` | Menu items selector. |
77
+ | ` activeClass ` | String | ` active ` | Class applied on menu item relative to the currently visible section. |
78
+ | ` threshold ` | Integer | ` 15 ` | Amount of space between your menu and the next section to be activated. |
79
+ | ` enableLocationHash ` | Boolean | ` true ` | Enable or disable browser's hash location change. |
80
+ | ` hashTimeout ` | Integer | ` 600 ` | Timeout to apply browser's hash location. |
81
+ | ` callback ` | Function | ` function(currentItem) {} ` | A function to be called every time a new menu item activates. |
0 commit comments