diff --git a/README.md b/README.md index 9bf3ec7..4293011 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ If you're not running any transpiler like babel, you'll most likely need to inst ## Usage -You should wrap your menu in a `` tag (which will be your nav) and add a `.scrollactive-item` class in your `` tags as I show in the example below: +The primary way to use the plugin is to wrap your menu in a `` tag (which will be your nav) and add a `.scrollactive-item` class in your `` tags as I show in the example below: ```html @@ -54,6 +54,19 @@ You should wrap your menu in a `` tag (which will be your nav) and 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 element ID that you would like to track while scrolling. +The secondary way to use it is almost the same as the primary but instead of relying on `href` to find your sections you'll need to set a data attribute `data-section-selector` on your elements with the section selector you wish to have. + +```html + + Home + About Us + Portfolio + Contact + +``` + +As you can see this gives you more freedom to choose different tags and you can use whatever CSS selector you find necessary, but it's important to notice that `data-section-selector` takes precedence over `href`, so if you have a tag `` it will completely ignore the `#section-1` and use `#another-section` instead. + ## Events Scrollactive will emit 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: diff --git a/src/scrollactive.vue b/src/scrollactive.vue index b7d101f..0f2a89b 100644 --- a/src/scrollactive.vue +++ b/src/scrollactive.vue @@ -1,7 +1,14 @@