Skip to content

Commit

Permalink
added skrollr.menu.click to programmatically trigger clicks
Browse files Browse the repository at this point in the history
  • Loading branch information
Prinzhorn committed May 10, 2014
1 parent 5e335e5 commit 6a1ecf0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ For example when you have a fixed navigation with a height of `100px`, then you
Note how the offset is negative, because we want to scroll down `100px` **less** than normal. Or in other words, we want to stop `100px` **before** the element. Positive values work the opposite way (scroll farther than usual).


Programmatically triggering a click
-----------------------------------

If you want to click one of the menu links programmatically, simply pass the link DOM element to the `skrollr.menu.click` function. Skrollr menu has to be initialized first!

```js
var link = document.querySelector('a');
skrollr.menu.click(link);
```


Changelog
====

Expand Down
6 changes: 6 additions & 0 deletions src/skrollr.menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@
jumpStraightToHash();
};

//Expose the handleLink function to be able to programmatically trigger clicks.
skrollr.menu.click = function(link) {
//We're not assigning it directly to `click` because of the second ("private") parameter.
handleLink(link);
};

//Private reference to the initialized skrollr.
var _skrollrInstance;

Expand Down

0 comments on commit 6a1ecf0

Please sign in to comment.