Skip to content

Commit

Permalink
feat: Add enable prop to control sync behavior (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
tech4him1 authored and okonet committed Aug 3, 2018
1 parent 5494e52 commit 0b4309b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ScrollSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ export default class ScrollSync extends Component {
children: PropTypes.element.isRequired,
proportional: PropTypes.bool,
vertical: PropTypes.bool,
horizontal: PropTypes.bool
horizontal: PropTypes.bool,
enabled: PropTypes.bool
};

static defaultProps = {
proportional: true,
vertical: true,
horizontal: true
horizontal: true,
enabled: true
};

static childContextTypes = {
Expand Down Expand Up @@ -75,6 +77,10 @@ export default class ScrollSync extends Component {
}

handlePaneScroll = (node, group) => {
if (!this.props.enabled) {
return
}

window.requestAnimationFrame(() => {
this.syncScrollPositions(node, group)
})
Expand Down
3 changes: 3 additions & 0 deletions src/example.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
To use ScrollSync you have to wrap your scrollable content (ensure that you have `overflow: auto`
in CSS) in `ScrollSyncPane` and then wrap everything in `ScrollSync`.

If you want to provide a toggle for users to turn the scroll syncing on and off, you can use the `enabled={false}` setting on the main `ScrollSync` element. Note that this disables the scroll syncing for all groups.

```
<ScrollSync>
Expand Down Expand Up @@ -102,3 +104,4 @@ Provide an arbitrary group name in the `group` prop to ScrollSyncPane components
</div>
</ScrollSync>
```

0 comments on commit 0b4309b

Please sign in to comment.