Skip to content

Commit 55d2d63

Browse files
committed
Added instructions for dynamic items
1 parent ccadeb6 commit 55d2d63

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Vue.use(Scrollactive);
2424
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:
2525

2626
```html
27-
<scrollactive class="my-nav">
27+
<scrollactive ref="scrollactive" class="my-nav">
2828
<a href="#home" class="scrollactive-item">Home</a>
2929
<a href="#about-us" class="scrollactive-item">About Us</a>
3030
<a href="#portfolio" class="scrollactive-item">Portfolio</a>
@@ -38,17 +38,29 @@ You can follow whatever structure you wish, just make sure to set the `.scrollac
3838
Scrollactive will emmit an `itemchanged(event, currentItem, lastActiveItem)` event when an active menu item is changed to another, you can catch that event doing as the example below:
3939

4040
```html
41-
<scrollactive class="my-nav" v-on:itemchanged="yourFunction()">
41+
<scrollactive ref="scrollactive" class="my-nav" v-on:itemchanged="yourFunction()">
4242
<a href="#home" class="scrollactive-item">Home</a>
4343
<a href="#about-us" class="scrollactive-item">About Us</a>
4444
<a href="#portfolio" class="scrollactive-item">Portfolio</a>
4545
<a href="#contact" class="scrollactive-item">Contact</a>
4646
</scrollactive>
4747
```
4848

49-
## Props configuration
50-
All options should be passed as a prop in the `<scrollactive>` component as you can see in the example below:
49+
## Dynamic menu items
50+
In order for the component to update when you add a new menu item, you must call the `setScrollactiveItems()` function. You can do that as I do in the example below:
51+
``` javascript
52+
methods: {
53+
dynamicItemsFunction() {
54+
// Add your items
55+
this.$refs.scrollactive.setScrollactiveItems();
56+
}
57+
}
58+
```
59+
60+
Make sure to set the `ref=scrollactive` property when you call the component in order to access the function as I do, or feel free to do it in any other way you would like, you just need to call the `setScrollactiveItems()` function.
5161

62+
## Configuration
63+
All options should be passed as a prop in the `<scrollactive>` component as you can see in the example below:
5264
``` html
5365
<scrollactive
5466
active-class="active"
@@ -58,6 +70,7 @@ All options should be passed as a prop in the `<scrollactive>` component as you
5870
</scrollactive>
5971
```
6072

73+
### Props
6174
``` javascript
6275
/**
6376
* Class that will be applied in the menu item.

0 commit comments

Comments
 (0)