Skip to content

Commit

Permalink
Reorganizing the Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmynotjim committed Nov 8, 2014
1 parent 1d87e74 commit da41203
Showing 1 changed file with 35 additions and 34 deletions.
69 changes: 35 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,48 @@ An `active` class is attached to the nav item matching the section that is the h

There are loading hooks added to the body element (similar to how Typekit handles font loading) to allow for css transitions or any other changes in css you'd need. When the plug-in starts `sn-loading` is added to the body class and is replaced by `sn-active` when the plugin is successful or `sn-failed` if it fails.

## Methods
## Destroy scrollNav

In addition to the initialization, there is now a destroy method available should you need it. To destroy scrollNav and remove all it's DOM changes use:

```
$('.post__article').scrollNav('destroy');
```


## Reset Positions on DOM Change

There are a couple of ways you can reset scrollNav's positions when the DOM changes:

### Manually

Simply call the `resetPos` method on your own:

```
$.fn.scrollNav('resetPos');
```

### Automatically

Utilize [mutation observers][21] to call the `resetPos` method automatically:

```
var $;
var observer_target = document.querySelector('.post__article');
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function() {
$.fn.scrollNav('resetPos');
});
});
var observer_config = {
attributes: true,
childList: true,
characterData: true,
subtree: true
};
observer.observe(observer_target, observer_config);
```

## Default `options`

There are a few customizable options in scrollNav using key : value pairs. These are the defaults.
Expand Down Expand Up @@ -199,39 +233,6 @@ $('.post__article').scrollNav({
});
```

## Reset Positions on DOM Change

There are a couple of ways you can reset scrollNav's positions when the DOM changes:

### Manually

Simply call the `resetPos` method on your own:

```
$.fn.scrollNav('resetPos');
```

### Automatically

Utilize [mutation observers][21] to call the `resetPos` method automatically:

```
var $;
var observer_target = document.querySelector('.post__article');
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function() {
$.fn.scrollNav('resetPos');
});
});
var observer_config = {
attributes: true,
childList: true,
characterData: true,
subtree: true
};
observer.observe(observer_target, observer_config);
```

## Errors

The plugin will refuse to build and log an error message if it doesn't find your desired container, the insertion target or any of the headlines specified within the container. If the nav doesn't show up on load, check your browser's console.
Expand Down

0 comments on commit da41203

Please sign in to comment.