Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize Documentation #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,36 @@ render() {
itemSpacing={20} />
);
}
```
To programmatical trigger the ScrollingMenu, create a ref and access to it like this:
```JavaScript
let items = ['Menu Item 1','Menu Item 2','Menu Item 3','Menu Item 4','Menu Item 5'];

onClick(itemIndex) {
console.log("Selected: " + items[itemIndex]);
}

render() {
return (
<ScrollingMenu
items={items}
ref={(c) => this.scrollingMenu = c}
callback={this.onClick.bind(this)}
backgroundColor="#ffffff"
textColor="#cccccc"
selectedTextColor="#000000"
itemSpacing={20} />
);
}
// Scrolling to Item 5:
this.scrollingMenu.scrollTo(5);

// Select item 5
this.scrollingMenu.select(5);

// accessing state of ScrollingMenu
this.scrollingMenu.state.selected;

```

## Props
Expand All @@ -43,3 +73,4 @@ render() {
|`textColor`|String (HEX)|The text color prior to being selected|
|`selectedTextColor`|String (HEX)|The text color of the selected item|
|`itemSpacing`|Number|The number of pixels between the menu items|