forked from joshwnj/react-visibility-sensor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
45 lines (39 loc) · 1.22 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
var Example = React.createClass({
getInitialState: function () {
return { msg: '' };
},
onChange: function (isVisible) {
this.setState({
msg: 'Element is now ' + (isVisible ? 'visible' : 'hidden')
});
},
render: function () {
var self = this;
return (
React.createElement("div", null,
React.createElement("p", {className: "msg"}, this.state.msg),
React.createElement("div", {className: "before"}),
React.createElement(VisibilitySensor, {
containment: this.props.containment,
onChange: this.onChange,
minTopValue: this.props.minTopValue,
partialVisibility: this.props.partialVisibility
},
React.createElement("div", {className: "sensor"})
),
React.createElement("div", {className: "after"})
)
);
}
});
ReactDOM.render(React.createElement(Example), document.getElementById('example'));
var container = document.getElementById('example-container');
var elem = container.querySelector('.inner');
container.scrollTop = 320;
container.scrollLeft = 320;
ReactDOM.render(React.createElement(Example, {
containment: container,
minTopValue: 10,
partialVisibility: true
}), elem);