-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
30 lines (29 loc) · 857 Bytes
/
index.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
var React = require('react');
var stickyPosition = require('sticky-position');
var createReactClass = require('create-react-class');
module.exports = createReactClass({
getDefaultProps: function() {
return {
className: 'sticky',
computeWidth: true,
tag: "div",
};
},
componentDidMount: function() {
this.sticky = stickyPosition({
primary: this.refs.primary,
placeholder: this.refs.placeholder,
wrapper: this.refs.wrapper,
computeWidth: this.props.computeWidth,
})
},
componentWillUnmount: function() {
this.sticky.destroy();
},
render: function() {
return React.createElement(this.props.tag, {ref: 'wrapper', className: this.props.className}, [
React.createElement(this.props.tag, {ref: 'primary', key: 0}, this.props.children),
React.createElement(this.props.tag, {ref: 'placeholder', key: 1})
]);
}
});