Skip to content

Commit 0a9d889

Browse files
committed
Updated for new event funcionality
1 parent 71bc0a8 commit 0a9d889

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Highlight your menu items as you scroll
2-
32
This vue 2 component makes it simple to highlight a menu item with an 'active' class as you scroll.
43

54
- Highlights menu items as you scroll
@@ -20,7 +19,7 @@ Vue.use(Scrollactive);
2019
```
2120

2221
## Usage
23-
You should wrap your menu in a `<scrollactive>` (which will be your nav) and add a .scrollactive-item class in your `<a>` tags as I show in the example below:
22+
You should wrap your menu in a `<scrollactive>` tag (which will be your nav) and add a `.scrollactive-item` class in your `<a>` tags as I show in the example below:
2423

2524
```html
2625
<scrollactive class="my-nav">
@@ -31,10 +30,21 @@ You should wrap your menu in a `<scrollactive>` (which will be your nav) and add
3130
</scrollactive>
3231
```
3332

34-
You can follow whatever structure you wish, just make sure to set the .scrollactive-item class in the items you want to highlight and set its `href` with a valid ID that you would like to scroll over.
33+
You can follow whatever structure you wish, just make sure to set the `.scrollactive-item` class in the items you want to highlight and set its `href` with a valid ID that you would like to track while scrolling.
3534

36-
## Props configuration
35+
## Events
36+
Scrollactive will fire an `itemchanged` event when an active menu item is changed to another, you can catch that event doing as the example below:
3737

38+
```html
39+
<scrollactive class="my-nav" v-on:itemchanged="yourFunction()">
40+
<a href="#home" class="scrollactive-item">Home</a>
41+
<a href="#about-us" class="scrollactive-item">About Us</a>
42+
<a href="#portfolio" class="scrollactive-item">Portfolio</a>
43+
<a href="#contact" class="scrollactive-item">Contact</a>
44+
</scrollactive>
45+
```
46+
47+
## Props configuration
3848
All options should be passed as a prop in the `<scrollactive>` component as you can see in the example below:
3949

4050
``` html

0 commit comments

Comments
 (0)