Skip to content

Commit ecd75bb

Browse files
author
David Schovanec
committed
Exclude inner wrap element from component
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.
1 parent 7069b80 commit ecd75bb

4 files changed

Lines changed: 47 additions & 13 deletions

File tree

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,31 @@ You can pass `true` as first argument for call callback after iscroll is initial
179179
}
180180
```
181181

182+
## Horizonzal scroll
183+
184+
Common usecase of horizontal scrolling
185+
186+
```js
187+
var React = require('react'),
188+
ReactIScroll = require('react-iscroll'),
189+
iScroll = require('iscroll');
190+
191+
var HorizontalScroll = React.createClass({
192+
render: function() {
193+
return (
194+
<ReactIScroll iscroll={iScroll}
195+
options={{mouseWheel: true, scrollbars: true, scrollX: true}}>
196+
<div style={{width:'200%'}}>
197+
<ul>
198+
{listOfLi}
199+
</ul>
200+
</div>
201+
</ReactIScroll>
202+
)
203+
}
204+
})
205+
```
206+
182207
## Example
183208

184209
There is example application. You can run it with this commands:

example/example.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ li {
9898
border-top: 1px solid #fff;
9999
background-color: #fafafa;
100100
font-size: 14px;
101+
102+
}
103+
104+
.beyond {
105+
float: right;
101106
}
102107

103108
.button {

example/example.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Example extends React.Component {
7575
let i = 0;
7676

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

8181
return (
@@ -89,11 +89,12 @@ class Example extends React.Component {
8989
options={IScrollOptions}
9090
onRefresh={this.onScrollRefresh}
9191
onScrollStart={this.onScrollStart}
92-
onScrollEnd={this.onScrollEnd}
93-
scrollerStyle={{width: "200%"}}>
94-
<ul>
95-
{listOfLi}
96-
</ul>
92+
onScrollEnd={this.onScrollEnd}>
93+
<div style={{width: "110%"}}>
94+
<ul>
95+
{listOfLi}
96+
</ul>
97+
</div>
9798
</ReactIScroll>
9899
</div>
99100
<div id="footer">

src/react-iscroll.jsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,15 @@ export default class ReactIScroll extends React.Component {
236236
}
237237

238238
render() {
239-
return (
240-
<div className={this.props.className} style={this.props.style}>
241-
<div style={this.props.scrollerStyle}>
242-
{this.props.children}
243-
</div>
244-
</div>
245-
)
239+
// Keep only html properties
240+
const htmlProps = {}
241+
242+
for(const prop in this.props) {
243+
if(!propTypes[prop]) {
244+
htmlProps[prop] = this.props[prop]
245+
}
246+
}
247+
248+
return <div {...htmlProps} />
246249
}
247250
}

0 commit comments

Comments
 (0)