Skip to content

Commit c29e6fa

Browse files
committed
Add proptypes to ScrollBlocker. Make sure to keep any existing props.
1 parent 1c4b6c9 commit c29e6fa

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ argument. If you want to change the timeout, override your components'
2020
## ScrollBlocker
2121

2222
A very simple component that allows you to block any mouse events during
23-
scrolling. Make sure to include ScrollBlocker.css somewhere in your CSS.
23+
scrolling.
2424

2525
## Example
2626

ScrollBlocker.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
/** @jsx React.DOM */
22
var React = require('react');
3-
var spread = require('react/lib/Object.assign');
43

5-
var style = {
4+
var blockerStyle = {
65
pointerEvents: 'none'
76
};
87

98
var ScrollBlocker = React.createClass({displayName: "ScrollBlocker",
109

10+
propTypes: {
11+
active: React.PropTypes.bool,
12+
style: React.PropTypes.object,
13+
children: React.PropTypes.node
14+
},
15+
1116
getDefaultProps: function () {
1217
return {
1318
active: false
1419
};
1520
},
1621

1722
render: function () {
23+
var { style, active, ...other } = this.props;
1824

1925
return (
20-
React.createElement("div", {style: spread({}, this.props.style, this.props.active && style)},
26+
React.createElement("div", React.__spread({}, other, {style: active && style}),
2127
this.props.children
2228
)
2329
);

jsx/ScrollBlocker.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,29 @@
22
var React = require('react');
33
var assign = require('react/lib/Object.assign');
44

5-
var style = {
5+
var blockerStyle = {
66
pointerEvents: 'none'
77
};
88

99
var ScrollBlocker = React.createClass({
1010

11+
propTypes: {
12+
active: React.PropTypes.bool,
13+
style: React.PropTypes.object,
14+
children: React.PropTypes.node
15+
},
16+
1117
getDefaultProps: function () {
1218
return {
1319
active: false
1420
};
1521
},
1622

1723
render: function () {
24+
var { style, active, ...other } = this.props;
1825

1926
return (
20-
<div style={assign({}, this.props.style, this.props.active && style)}>
27+
<div {...other} style={assign({}, style, active && blockerStyle)}>
2128
{this.props.children}
2229
</div>
2330
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-scroll-components",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "A set of components that react to page scrolling",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)