Skip to content

Commit

Permalink
Major Update, new ScrollToActionElement, active state in Provider, ex…
Browse files Browse the repository at this point in the history
…ample added
  • Loading branch information
philippsiegmund committed Jun 13, 2019
1 parent f32cbf2 commit 719c720
Show file tree
Hide file tree
Showing 19 changed files with 15,022 additions and 49 deletions.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ import ScrollToProvider from '@zauberware/react-scroll-to'
```

### NEW with v 0.2.1

### ScrollToActionElement
You can use the included ScrollToAction element with a scrollTo action already attached.

```
# Renders a passed Component and adds 'active' property
<ScrollToActionElement Parent={Button} target='mysection' />
```
The rendered element has the property active='active', so you can with styled-components

### Usage

#### addScrollRef()
Expand All @@ -48,9 +61,10 @@ handleClick = (target) => {
<a logo onClick={() => this.handleClick('mysection')}>My Section</a>
```

#### Add Context

#### LEGACY IMPLEMENTATION BEFORE v0.2.1!

Define your contextTypes:

```
Expand All @@ -61,3 +75,13 @@ MyComponent.contextTypes = {
}
```
Note: You only need to define the types or functions you want to use. You may only need addScrollRef on your scroll target and e.g. scrollTo within your MenuComponent.

#### IMPLEMENTATION v0.2.1!

```
import ScrollToContext from '@zauberware/react-scroll-to'
[...]
MyComponent.contextType = ScrollToContext
```
2 changes: 1 addition & 1 deletion build/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
Loading

0 comments on commit 719c720

Please sign in to comment.