Skip to content

Commit

Permalink
Exclude inner wrap element from component
Browse files Browse the repository at this point in the history
Component solve only default behavior. “Fill space with div, which
content will be scrollable”
If you want to have horizontal scrolling, or custom styling you can
wrap content of component to your own div.
You can still overwrite iscroll element styles or add custom class with
style and className properties on component.
  • Loading branch information
David Schovanec committed Dec 19, 2015
1 parent 7069b80 commit ecd75bb
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 13 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,31 @@ You can pass `true` as first argument for call callback after iscroll is initial
}
```

## Horizonzal scroll

Common usecase of horizontal scrolling

```js
var React = require('react'),
ReactIScroll = require('react-iscroll'),
iScroll = require('iscroll');

var HorizontalScroll = React.createClass({
render: function() {
return (
<ReactIScroll iscroll={iScroll}
options={{mouseWheel: true, scrollbars: true, scrollX: true}}>
<div style={{width:'200%'}}>
<ul>
{listOfLi}
</ul>
</div>
</ReactIScroll>
)
}
})
```

## Example

There is example application. You can run it with this commands:
Expand Down
5 changes: 5 additions & 0 deletions example/example.css
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ li {
border-top: 1px solid #fff;
background-color: #fafafa;
font-size: 14px;

}

.beyond {
float: right;
}

.button {
Expand Down
13 changes: 7 additions & 6 deletions example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Example extends React.Component {
let i = 0;

for(i; i < len; i++) {
listOfLi.push(<li key={i}>Pretty row {this.state.list[i]}</li>)
listOfLi.push(<li key={i}>Pretty row {this.state.list[i]}<span className="beyond">I'm beyond</span></li>)
}

return (
Expand All @@ -89,11 +89,12 @@ class Example extends React.Component {
options={IScrollOptions}
onRefresh={this.onScrollRefresh}
onScrollStart={this.onScrollStart}
onScrollEnd={this.onScrollEnd}
scrollerStyle={{width: "200%"}}>
<ul>
{listOfLi}
</ul>
onScrollEnd={this.onScrollEnd}>
<div style={{width: "110%"}}>
<ul>
{listOfLi}
</ul>
</div>
</ReactIScroll>
</div>
<div id="footer">
Expand Down
17 changes: 10 additions & 7 deletions src/react-iscroll.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,15 @@ export default class ReactIScroll extends React.Component {
}

render() {
return (
<div className={this.props.className} style={this.props.style}>
<div style={this.props.scrollerStyle}>
{this.props.children}
</div>
</div>
)
// Keep only html properties
const htmlProps = {}

for(const prop in this.props) {
if(!propTypes[prop]) {
htmlProps[prop] = this.props[prop]
}
}

return <div {...htmlProps} />
}
}

0 comments on commit ecd75bb

Please sign in to comment.